John Bachir wrote:
> i've read other posts on this list that say that we can't guess what sqlite
> will do with cache.

It uses a simple LRU algorithm to determine which pages to kick out of
the page cache first (so at least it's somewhat deterministic).

> however, could i be relatively confident that most of the time, it
> will prioritize keeping the index in memory before it starts keeping
> the data?

The page cache does not know what is in the pages.

Let's look at a simple example: assume the index has two pages, X and Y,
which each point to records in three data pages:
  X -> A,B,C; Y -> D,E,F

The order in which the pages would be used is this:
  X A X B X C Y D Y E Y F

For LRU, the last usage matters, so the LRU list will look like this:
  A B X C D E Y F

So the data pages _will_ crowd out the index pages (especially when
there are much fewer index then data pages ).

> ideally it would always keep the entire index in memory and never
> cache the data.
>
> if i can't more or less depend on this, then sqlite probably won't
> work for my application.

You could write your own page cache implementation that wraps the
original one but never throws out certain pages ...


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to