-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression test for native postgres scan. Handle COUNT(*) in batches.
- Loading branch information
Showing
7 changed files
with
290 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
CREATE TABLE t1(a INT, b INT, c TEXT); | ||
INSERT INTO t1 SELECT g, g % 100, 'scan_potgres_table_'||g from generate_series(1,100000) g; | ||
SET client_min_messages TO DEBUG1; | ||
-- COUNT(*) | ||
SELECT COUNT(*) FROM t1; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT COUNT(*) FROM public.t1 | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Aggregate | ||
-> Parallel Seq Scan on t1 | ||
|
||
count | ||
-------- | ||
100000 | ||
(1 row) | ||
|
||
-- SEQ SCAN | ||
SELECT COUNT(a) FROM t1 WHERE a < 10; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a<10 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Seq Scan on t1 | ||
Filter: ((a IS NOT NULL) AND (a < 10)) | ||
|
||
count | ||
------- | ||
9 | ||
(1 row) | ||
|
||
-- CREATE INDEX on t1 | ||
SET client_min_messages TO DEFAULT; | ||
CREATE INDEX ON t1(a); | ||
SET client_min_messages TO DEBUG1; | ||
-- BITMAP INDEX | ||
SELECT COUNT(a) FROM t1 WHERE a < 10; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a<10 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Bitmap Heap Scan on t1 | ||
Recheck Cond: ((a < 10) AND (a IS NOT NULL)) | ||
-> Bitmap Index Scan on t1_a_idx | ||
Index Cond: ((a < 10) AND (a IS NOT NULL)) | ||
|
||
count | ||
------- | ||
9 | ||
(1 row) | ||
|
||
-- INDEXONLYSCAN | ||
SET enable_bitmapscan TO false; | ||
SELECT COUNT(a) FROM t1 WHERE a = 1; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a=1 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Index Only Scan using t1_a_idx on t1 | ||
Index Cond: ((a IS NOT NULL) AND (a = 1)) | ||
|
||
count | ||
------- | ||
1 | ||
(1 row) | ||
|
||
-- INDEXSCAN | ||
SELECT COUNT(c) FROM t1 WHERE a = 1; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT c FROM public.t1 WHERE (a=1 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Index Scan using t1_a_idx on t1 | ||
Index Cond: ((a IS NOT NULL) AND (a = 1)) | ||
|
||
count | ||
------- | ||
1 | ||
(1 row) | ||
|
||
-- TEMPORARY TABLES JOIN WITH HEAP TABLES | ||
SET client_min_messages TO DEFAULT; | ||
CREATE TEMP TABLE t2(a int); | ||
INSERT INTO t2 VALUES (1), (2), (3); | ||
SET client_min_messages TO DEBUG1; | ||
SELECT t1.a, t2.a FROM t1, t2 WHERE t1.a = t2.a; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM pg_temp.t2 | ||
RUNNING: IN PROCESS THREAD. | ||
EXECUTING: | ||
Seq Scan on t2 | ||
|
||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a>=1 AND a<=3 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Index Only Scan using t1_a_idx on t1 | ||
Index Cond: ((a >= 1) AND (a <= 3) AND (a IS NOT NULL)) | ||
|
||
a | a | ||
---+--- | ||
1 | 1 | ||
2 | 2 | ||
3 | 3 | ||
(3 rows) | ||
|
||
-- JOIN WITH SAME TABLE (on WORKERS) | ||
SELECT COUNT(*) FROM t1 AS t1_1, t1 AS t1_2 WHERE t1_1.a < 2 AND t1_2.a > 8; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a<2 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Seq Scan on t1 | ||
Filter: ((a IS NOT NULL) AND (a < 2)) | ||
|
||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a>8 AND a IS NOT NULL) | ||
RUNNING: ON 1 PARALLEL WORKER(S). | ||
EXECUTING: | ||
Parallel Seq Scan on t1 | ||
Filter: ((a IS NOT NULL) AND (a > 8)) | ||
|
||
count | ||
------- | ||
99992 | ||
(1 row) | ||
|
||
-- JOIN WITH SAME TABLE (in BACKEND PROCESS) | ||
SET max_parallel_workers TO 0; | ||
SELECT COUNT(*) FROM t1 AS t1_1, t1 AS t1_2 WHERE t1_1.a < 2 AND t1_2.a > 8; | ||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a<2 AND a IS NOT NULL) | ||
RUNNING: IN PROCESS THREAD. | ||
EXECUTING: | ||
Parallel Seq Scan on t1 | ||
Filter: ((a IS NOT NULL) AND (a < 2)) | ||
|
||
DEBUG: (PGDuckdDB/PostgresTableReader) | ||
|
||
QUERY: SELECT a FROM public.t1 WHERE (a>8 AND a IS NOT NULL) | ||
RUNNING: IN PROCESS THREAD. | ||
EXECUTING: | ||
Parallel Seq Scan on t1 | ||
Filter: ((a IS NOT NULL) AND (a > 8)) | ||
|
||
count | ||
------- | ||
99992 | ||
(1 row) | ||
|
||
SET max_parallel_workers TO DEFAULT; | ||
SET enable_bitmapscan TO DEFAULT; | ||
SET client_min_messages TO DEFAULT; | ||
DROP TABLE t1, t2; |
Oops, something went wrong.