Open GoogleCodeExporter opened 9 years ago
Original comment by dtab...@gmail.com
on 23 May 2014 at 9:03
I think the root of the issue is that this predicate is incorrectly
rewritten/sarged. This *entire* predicate cannot actually be supported by our
btree as a range predicate over both fields of the composite key since the
search cursor only supports contiguous intervals (ranges). In other words, the
range (<5,0>, <+inf,+inf>) is a superset of all keys with a > 5 and b > 0 (e.g.
<6, -1>). Without implementing a specialized search cursor, what we could do is:
1) Use the b+tree to find all items with a > 5
2) Use a select operator to filter b > 0 afterwards
Thoughts?
Original comment by zheilb...@gmail.com
on 24 May 2014 at 8:35
I think searching the b+tree with both predicates is OK as long as you keep the
original select operator, which will obviously prune "most" of the false
positives as opposed if you just use a single predicate to query the tree.
Original comment by salsuba...@gmail.com
on 24 May 2014 at 10:07
Actually, I don't understand how searching the btree with both predicates will
work.
Consider the following sequence of keys that might exist in the btree:
<6, 1>, <7, -1>, <8, 10>
Using a search predicate of a > 5, b > 0, then the cursor will find and return
<6, 1>, but will not return <7, -1>. Moreover, the cursor will stop, neglecting
<8, 10> which satisfies the predicate.
Do you agree?
Original comment by zheilb...@gmail.com
on 25 May 2014 at 3:14
Actually that's not how the btree range cursor is implemented. We don't compare
every record with the search key. Instead, whenever a new leaf page is fetched,
we binary search it and decide what is the last record's index that should be
part of the result set. Once this is decided, all records with smaller indexes
are returned as result.
Original comment by salsuba...@gmail.com
on 25 May 2014 at 4:25
Right, so when you binary search and land on <6, -1>, what happens?
Original comment by zheilb...@gmail.com
on 25 May 2014 at 4:28
Ah, so you might get end up with false negatives too. It is even worse than
what I thought :-)
So my second solution is out of the picture. Either do my first solution, or do
some sort of prefix search that still guarantee you will get the correct result
and filter out the false positives. You might want to double check your
proposal always guarantee to return the correct result for all different
scenarios (e.g., composite keys with more than 2 fields and different search
predicates).
Original comment by salsuba...@gmail.com
on 25 May 2014 at 4:42
Original issue reported on code.google.com by
salsuba...@gmail.com
on 23 May 2014 at 2:39Attachments: