Skip to content
Snippets Groups Projects
Commit b1d73e0c authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Roman Tsisyk
Browse files

vinyl: read iterator: do not fetch statements found in the cache

When the read iterator stops reading a chain of statements from the
cache it advances all other sources by calling next_key() until the
last_stmt is reached. This effectively cancels the benefit of using
the cache, because all statements skipped due to the cache are fetched
from in-memory trees or, even worse, on-disk runs.

To fix this, let's introduce and use skip() method which makes the
source iterator jump to the first statement following a particular key.
Its implementation is similar to and reuses the code from start and
restore procedures.

With this new method, we don't need to mangle iterator_type/key when
reopening source iterators during restoration so that they start
iteration from last_stmt: instead we can advance them with skip() on
the first iteration. Let's do this too, because the iterator can
benefit from knowing the real iterator type (e.g. cache can stop
ITER_EQ iteration even if there's no chain in the cache, by looking at
vy_cache_entry::left_boundary_level,right_boundary_level).
parent 89ef2c76
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment