Fork me on GitHub
#xtdb
<
2023-11-09
>
djtango17:11:21

@taylor.jeremydavid How does caching work in XTDB? If we have:

(def node (xt/new-api-client "url:5511"))
(def db (xt/db node))
(xt/q db '{:find [e] :where [[e :xt/id id]]})
(xt/q db '{:find [e] :where [[e :xt/id id]]})
(xt/q db '{:find [e] :where [[e :xt/id id]]})
(xt/q db '{:find [e] :where [[e :xt/id id]]})
Do the calls get cached in the client at all?

refset17:11:46

Hey @U0HJD63RN there's no caching at the client level so each of these will execute independently, in full. Caching that does happen across the queries though: 1. RocksDB will keep recently used pages in memory 2. There's an entity cache attached to the db which will short circuit some of the internal temporal version lookups, also "LRU" based 3. The query is compiled and cached so the Datalog won't be being parsed each time (although this saving is minuscule in the scheme of things, especially if you have any kind of network latency)

nivekuil18:11:02

I would add that the basis-t of the query is set when you call (xt/db node) so if you reuse db here it could look like it's caching

👍 2
refset20:11:04

> the basis-t of the query is set when you call (xt/db node) so if you reuse db here it could look like it's caching yep that's the "entity cache" I meant in #2 - it is in service of the basis-t concept