# Database micro-benchmark (Discussion)

**URL:** <https://swi-prolog.discourse.group/t/database-micro-benchmark-discussion/3208>\
**Category:** Discussion\
**Created:** [September 11, 2019, 8:10pm UTC](https://swi-prolog.discourse.group/t/database-micro-benchmark-discussion/3208 "2019-09-11T20:10:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 12, 2019, 7:25am UTC](https://swi-prolog.discourse.group/t/database-micro-benchmark-discussion/3208/4 "2019-09-12T07:25:48Z")

</div>

> [@Database micro-benchmark](https://swi-prolog.discourse.group/t/database-micro-benchmark/1231/1):
>
> I wonder if the `assert` lookup speeds up considerably on the second run because of JIT indexing?

Yes

> [@Database micro-benchmark](https://swi-prolog.discourse.group/t/database-micro-benchmark/1231/1):
>
> I guess the (dynamic) tabling code is making thinks a little bit slower in the dev version.

No. Anyway, that would only affect the assert/retract case. The hooks for dealing with incremental udates of tables are realised using different _preample_ (supervisor) code for incremental dynamic predicates. There is a very quick check for a flag in assert/retract to call update hooks. These really matter for dynamic incremental predicates, but should not be measurable otherwise.

There is a general extra price for meta-calling due to the wrap\_predicate/4 primitive. The effect seems pretty small though.

I cannot reproduce your figures. Over the whole run I get 3.78 (8.13) vs. 3.67 (8.03). This figure varies a bit between runs and boils down to 3%. Note that re-compiling the system with trivial changes often leads to a few percent difference, I guess due to different cache behavior.

Note that loading `library(apply_macros)` makes more difference as this inlines forall/2 rather than meta-calling it. Also using `scripts/pgo-compile.sh` to build the system is likely to make more difference.

Did you really compile on the same machine with the same compiler and same configuration?

---

_[View the full topic](https://swi-prolog.discourse.group/t/database-micro-benchmark-discussion/3208)._
