Ran
|
Files
479
|
Run time
25s
|
Badge
Embed ▾
README BADGES
|
push
github
vinyl: enable exact match optimization for unique secondary indexes If the iterator type is EQ/REQ/LE/GE and the search key is exact (that is, there may be at most one tuple matching the key in the index), there's no need to scan disk levels if we found a statement for this key in the memory level. We've had this optimization for ages but it worked only for full keys in terms `cmp_def` (key definition extended with primary key parts). Apparently, a lookup in a secondary index performed by the user wouldn't match these criteria unless the secondary index explicitly included all primary key parts. This commit improves on that. Now, we enable the optimization if the search key is **exact**. We consider a key **exact** if either of the following conditions is true: - The key statement is a tuple (tuple has all key parts). - The key statement is a full key in terms of `cmp_def`. - The key statement is a full key in terms of `key_def`, it doesn't contain nulls, and the index is unique. The check for nulls is necessary because even a unique nullable index may contain more than one equal key with nulls. Note, this patch slightly refactors the optimization, adding a few comments and hopefully making it more understandable. In particular, we remove the one-result-tuple optimization for exact EQ/REQ from `vy_read_iterator_advance` and put it in `vy_read_iterator_evaluate_src` instead. This way the whole optimization resides in one place. Closes #10442 NO_DOC=bug fix (cherry picked from commit 850673db5)
62984 of 114227 branches covered (55.14%)
93876 of 109284 relevant lines covered (85.9%)
2462083.21 hits per line
Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line | Branch Hits | Branch Misses |
---|