-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: partition table query optimize (#1594)
## Rationale Close #1441 ## Detailed Changes ### TLDR The performance issue with inlist queries is due to the extra overhead from bloom-filter-like directory lookups when scanning each SST file for rows. The solution is to create a separate predicate for each partition, containing only the keys relevant to that partition. Since the current partition filter only supports BinaryExpr(Column, operator, Literal) and non-negated InList expressions, this solution will address only those specific cases. ### Changes 1. During the scan building process, when identifying the partitions for a query, we create a PartitionedFilterKeyIndex variable to store the predicate key indices for each expression. 2. In the compute_partition_for_keys_group function, we use a HashMap<partition_id, HashMap<filter_index, BTreeSet<key_index>>> to record the indices of keys involved in partition computation for each group. 3. In the partitioned_predicates function, we construct the final predicates for each partition. 4. In resolve_partitioned_scan_internal, we generate separate requests for each partition. e.g. conditions: 1. table schema: col_ts, col1, col2, in which col1 and col2 are both keys, and with two partitions 2. sql: select * from table where col1 = '33' and col2 in ("aa", "bb", "cc", "dd") partition expectations: yield two predicates p0: col1 = '33' and col2 in ("aa", "bb", "cc"); p1: col1 = '33' and col2 in ("dd") ### Other issues discovered When the inlist key args length is less than three, Expr will be refactored to nested BinaryExpr which bypasses the FilterExtractor. e.g. SQL: select * from table where col1 in ("aa", "bb") and col2 in (1,2,3,4,5...1000) Since ("aa", "bb") has fewer than three elements, the col1 key filter is not included in partition computation, which interrupts the partitioning process in the get_candidate_partition_keys_groups function, as contains_empty_filter is set to true. ## Test Plan 1. UT: test_partitioned_predicate 2. Manual test. --------- Co-authored-by: jiacai2050 <[email protected]>
- Loading branch information
1 parent
2176524
commit e2970b1
Showing
15 changed files
with
418 additions
and
62 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
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.