-
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore NULLs (if desired) while scanning keys during index navigation #8446
Conversation
src/jrd/recsrc/IndexTableScan.cpp
Outdated
// If we're walking in a descending index and we need to ignore NULLs | ||
// then stop at the first NULL we see (only for single segment!) | ||
if (descending && ignoreNulls && node.prefix == 0 && | ||
node.length >= 1 && node.data[0] == 255) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accordingly to the compress()
:
// Further a NULL state is always returned as 1 byte 0xFF (descending index).
So, why check for >= 1
, not == 1
?
And, for consistency, please use 0xFF, not 255.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy-paste from btr.cpp :) where such a check is used twice. I don't mind changing it, but I'd suggest this to be done in btr.cpp too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also wondering whether we really should check for (node.prefix == 0 && node.length == 1 && node.data[0] == 0xFF)
-- i.e. the first NULL encountered -- or better for (node.prefix + node.length == 1 && node.data[0] == 0xFF)
-- i.e. any NULL encountered, as more reliable. Is it theoretically possible that we somehow jump to the bucket in the middle of the NULL duplicates chain and start scanning from there, thus skipping the first NULL node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also wondering whether we really should check for
(node.prefix == 0 && node.length == 1 && node.data[0] == 0xFF)
-- i.e. the first NULL encountered -- or better
for
(node.prefix + node.length == 1 && node.data[0] == 0xFF)
-- i.e. any NULL encountered, as more reliable.
Second way is not correct: when node.length == 0
we should not access node.data[0]
at all.
Instead, we could look at key
contents, if necessary.
Is it theoretically possible that we somehow jump to the bucket in the middle of the NULL duplicates chain and start scanning from there, thus skipping the first NULL node?
The position is based on the last key processed, so, we should be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy-paste from btr.cpp :) where such a check is used twice. I don't mind changing it, but I'd suggest this to be done in btr.cpp too.
Ok, then, let it be this way
QA note: ticket issue is covered by test for 8291 (it was enough to reduce MAX_ALLOWED_IDX_READS threshold, see notes there). |
See also #8291. This improvement completes the solution by extending the "ignore null" checks to the scan phase. The logic mostly matches
btr.cpp
(BTR_evaluate()
andscan()
).With the same test case, results are:
before this PR:
after this PR:
-- Fetches = 7