-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…he range key Summary: ScanChoices is an iterator type that iterates over tuples allowed by a given query filter in the DocDB layer. Currently, there are two types of ScanChoices based on filter type. 1. Scan choices that iterates over discrete filters: these work with filters of the form `x` IN (a, b, c) AND `y` IN (d,e,f) where a,b,c,d,e,f are all discrete values and `x`, `y` are table columns. We call this type DiscreteScanChoices. In this example, a DiscreteScanChoices would iterate over the space (a,b,c) x (d,e,f). 2. Another type of ScanChoices operates over filters that express ranges of values such as a <= x <= b where x is a table column and a, b are discrete values. We call this type RangeBasedScanChoices. In this example, the RangeBasedScanChoices would iterate over the space (a,....,b). A shortcoming of this approach of having different ScanChoices implementations for different filter types is that it cannot support a mixture of the two filter types. If we consider a filter of the form x IN (a,b,c,d,e,f) AND p <= y <= q, then we are forced to choose either using DiscreteScanChoices and only being able to process the filter for x or the alternative where we can only process the filter on y. This diff introduces HybridScanChoices which aims to support both types of filters. It treats both filter types as part of a larger class of filters that are conceptualized as lists of ranges as opposed to lists of values or singular ranges. It converts a filter of the form r1 IN (a,b,c,d) to r1 IN ([a,a], [b,b], [c,c], [d,d]). A range filter of the form a <= r1 <= b is converted into r1 IN ([a,b]). Unifying the way filters are interpreted at the DocDB iteration level and allows much more efficient queries. Consider the following table and query: CREATE TABLE sample (h int, r1 int, r2 int, primary key(h HASH, r1 ASC, r2 ASC)); SELECT * FROM sample WHERE h = 1 and r1 IN (1, 4) and r2 <= 5; Previously, the filter r1 IN (1,4) would have been converted to r1 >= 1 AND r1 <= 4 before processing. With this diff, that need not happen. A filter on a subset of the range key yielded a similar scenario: SELECT * FROM sample WHERE h = 1 and r1 IN (1, 5, 6); In this query, there is an implicit range filter on r2 from -Inf to +Inf. This was also treated as a mixed filter, causing the filter on r1 to be converted to a range filter again. This diff helps these such queries as well. This feature can be disabled by setting the runtime GFlag, disable_hybrid_scan to true. Test Plan: ``` ./yb_build --java-test 'org.yb.pgsql.TestPgSelect' ``` ``` ./yb_build --java-test 'org.yb.cql.TestSelect' ``` Reviewers: rskannan, amitanand, mtakahara Reviewed By: mtakahara Subscribers: kannan, rsami, zyu, yql Differential Revision: https://phabricator.dev.yugabyte.com/D12617
- Loading branch information
1 parent
242d14c
commit 323f2ca
Showing
8 changed files
with
897 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.