forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[yugabyte#14559][YSQL][YCQL] Implement select distinct pushdown to DocDB
Summary: We implement pushdown for SELECT DISTINCT query. We extend the Hybrid Scan work to support scanning tuple prefixes. Specifically, with a given prefix length, Hybrid Scan will advance to the next prefix that is different from the previous one. We need to determine the prefix length to be used when scanning in DocDB. This should equal the index of the last column to be requested in the scan. Test Plan: unit test added. A example to demonstrate pushdown working as intended: Populate data ``` yugabyte=# create table t(h int, c int); CREATE TABLE create index idx on t(h ASC, c ASC); yugabyte=# insert into t (select 1, i from generate_series(1, 1000000) as i); INSERT 0 1000000 yugabyte=# insert into t (select 2, i from generate_series(1, 1000000) as i); INSERT 0 1000000 ``` Before ``` yugabyte=# explain analyze select distinct h from t where h <= 2; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- Unique (cost=0.00..15.50 rows=82 width=4) (actual time=7.259..12649.788 rows=2 loops=1) -> Index Only Scan using idx on t (cost=0.00..15.25 rows=100 width=4) (actual time=7.255..12415.214 rows=2000000 loops=1) Index Cond: (h <= 2) Heap Fetches: 0 Planning Time: 0.094 ms Execution Time: 12649.868 ms Peak Memory Usage: 8 kB (7 rows) ``` After ``` yugabyte=# explain analyze select distinct h from t where h <= 2; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- Unique (cost=0.00..15.50 rows=82 width=4) (actual time=2.182..2.191 rows=2 loops=1) -> Index Only Scan using idx on t (cost=0.00..15.25 rows=100 width=4) (actual time=2.178..2.183 rows=2 loops=1) Index Cond: (h <= 2) Heap Fetches: 0 Planning Time: 0.113 ms Execution Time: 2.274 ms Peak Memory Usage: 8 kB (7 rows) ``` Reviewers: smishra, amartsinchyk, pjain, tnayak Reviewed By: tnayak Subscribers: rskannan, yql, kannan, smishra Differential Revision: https://phabricator.dev.yugabyte.com/D20742
- Loading branch information
1 parent
c97640f
commit 1524735
Showing
20 changed files
with
375 additions
and
37 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.