Skip to content

Commit cf3e182

Browse files
authored
Stabilize the compression_qualpushdown test (#8004)
Add some VACUUMs.
1 parent aad65d0 commit cf3e182

File tree

2 files changed

+63
-52
lines changed

2 files changed

+63
-52
lines changed

tsl/test/expected/compression_qualpushdown.out

+57-52
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- This file and its contents are licensed under the Timescale License.
22
-- Please see the included NOTICE for copyright information and
33
-- LICENSE-TIMESCALE for a copy of the license.
4+
set max_parallel_workers_per_gather = 0;
45
-- qual pushdown tests for decompresschunk ---
56
-- Test qual pushdown with ints
67
CREATE TABLE meta (device_id INT PRIMARY KEY);
@@ -268,6 +269,7 @@ EXPLAIN (costs off) SELECT * FROM pushdown_relabel WHERE dev_vc = 'varchar'::cha
268269
Filter: ((dev_vc)::bpchar = 'varchar '::character(10))
269270
(4 rows)
270271

272+
RESET enable_seqscan;
271273
-- github issue #5286
272274
CREATE TABLE deleteme AS
273275
SELECT generate_series AS timestamp, 1 AS segment, 0 AS data
@@ -292,6 +294,7 @@ SELECT compress_chunk(i) FROM show_chunks('deleteme') i;
292294
_timescaledb_internal._hyper_7_8_chunk
293295
(1 row)
294296

297+
VACUUM ANALYZE deleteme;
295298
EXPLAIN (costs off) SELECT sum(data) FROM deleteme WHERE segment::text like '%4%';
296299
QUERY PLAN
297300
---------------------------------------------------------
@@ -368,95 +371,96 @@ SELECT compress_chunk(show_chunks('svf_pushdown'));
368371
_timescaledb_internal._hyper_11_12_chunk
369372
(1 row)
370373

374+
VACUUM ANALYZE svf_pushdown;
371375
-- constraints should be pushed down into scan below decompresschunk in all cases
372376
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_date = CURRENT_DATE;
373-
QUERY PLAN
374-
----------------------------------------------------------------------------------------------------------------------------
377+
QUERY PLAN
378+
-----------------------------------------------------------
375379
Custom Scan (ChunkAppend) on svf_pushdown
376380
Chunks excluded during startup: 0
377381
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
378-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
379-
Index Cond: (c_date = CURRENT_DATE)
382+
-> Seq Scan on compress_hyper_12_13_chunk
383+
Filter: (c_date = CURRENT_DATE)
380384
(5 rows)
381385

382386
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timetz = CURRENT_TIME;
383-
QUERY PLAN
384-
----------------------------------------------------------------------------------------------------------------------------
387+
QUERY PLAN
388+
-----------------------------------------------------------
385389
Custom Scan (ChunkAppend) on svf_pushdown
386390
Chunks excluded during startup: 0
387391
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
388-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
389-
Index Cond: (c_timetz = CURRENT_TIME)
392+
-> Seq Scan on compress_hyper_12_13_chunk
393+
Filter: (c_timetz = CURRENT_TIME)
390394
(5 rows)
391395

392396
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timetz = CURRENT_TIME(1);
393-
QUERY PLAN
394-
----------------------------------------------------------------------------------------------------------------------------
397+
QUERY PLAN
398+
-----------------------------------------------------------
395399
Custom Scan (ChunkAppend) on svf_pushdown
396400
Chunks excluded during startup: 0
397401
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
398-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
399-
Index Cond: (c_timetz = CURRENT_TIME(1))
402+
-> Seq Scan on compress_hyper_12_13_chunk
403+
Filter: (c_timetz = CURRENT_TIME(1))
400404
(5 rows)
401405

402406
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = CURRENT_TIMESTAMP;
403-
QUERY PLAN
404-
----------------------------------------------------------------------------------------------------------------------------
407+
QUERY PLAN
408+
-----------------------------------------------------------
405409
Custom Scan (ChunkAppend) on svf_pushdown
406410
Chunks excluded during startup: 0
407411
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
408-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
409-
Index Cond: (c_timestamp = CURRENT_TIMESTAMP)
412+
-> Seq Scan on compress_hyper_12_13_chunk
413+
Filter: (c_timestamp = CURRENT_TIMESTAMP)
410414
(5 rows)
411415

412416
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = CURRENT_TIMESTAMP(1);
413-
QUERY PLAN
414-
----------------------------------------------------------------------------------------------------------------------------
417+
QUERY PLAN
418+
------------------------------------------------------------
415419
Custom Scan (ChunkAppend) on svf_pushdown
416420
Chunks excluded during startup: 0
417421
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
418-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
419-
Index Cond: (c_timestamp = CURRENT_TIMESTAMP(1))
422+
-> Seq Scan on compress_hyper_12_13_chunk
423+
Filter: (c_timestamp = CURRENT_TIMESTAMP(1))
420424
(5 rows)
421425

422426
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_time = LOCALTIME;
423-
QUERY PLAN
424-
----------------------------------------------------------------------------------------------------------------------------
427+
QUERY PLAN
428+
-----------------------------------------------------------
425429
Custom Scan (ChunkAppend) on svf_pushdown
426430
Chunks excluded during startup: 0
427431
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
428-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
429-
Index Cond: (c_time = LOCALTIME)
432+
-> Seq Scan on compress_hyper_12_13_chunk
433+
Filter: (c_time = LOCALTIME)
430434
(5 rows)
431435

432436
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_time = LOCALTIME(1);
433-
QUERY PLAN
434-
----------------------------------------------------------------------------------------------------------------------------
437+
QUERY PLAN
438+
-----------------------------------------------------------
435439
Custom Scan (ChunkAppend) on svf_pushdown
436440
Chunks excluded during startup: 0
437441
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
438-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
439-
Index Cond: (c_time = LOCALTIME(1))
442+
-> Seq Scan on compress_hyper_12_13_chunk
443+
Filter: (c_time = LOCALTIME(1))
440444
(5 rows)
441445

442446
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = LOCALTIMESTAMP;
443-
QUERY PLAN
444-
----------------------------------------------------------------------------------------------------------------------------
447+
QUERY PLAN
448+
-----------------------------------------------------------
445449
Custom Scan (ChunkAppend) on svf_pushdown
446450
Chunks excluded during startup: 0
447451
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
448-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
449-
Index Cond: (c_timestamp = LOCALTIMESTAMP)
452+
-> Seq Scan on compress_hyper_12_13_chunk
453+
Filter: (c_timestamp = LOCALTIMESTAMP)
450454
(5 rows)
451455

452456
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = LOCALTIMESTAMP(1);
453-
QUERY PLAN
454-
----------------------------------------------------------------------------------------------------------------------------
457+
QUERY PLAN
458+
-----------------------------------------------------------
455459
Custom Scan (ChunkAppend) on svf_pushdown
456460
Chunks excluded during startup: 0
457461
-> Custom Scan (DecompressChunk) on _hyper_11_12_chunk
458-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
459-
Index Cond: (c_timestamp = LOCALTIMESTAMP(1))
462+
-> Seq Scan on compress_hyper_12_13_chunk
463+
Filter: (c_timestamp = LOCALTIMESTAMP(1))
460464
(5 rows)
461465

462466
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_name = USER;
@@ -520,35 +524,35 @@ EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_name = CURRENT_SCHEMA;
520524
(5 rows)
521525

522526
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_bool;
523-
QUERY PLAN
524-
----------------------------------------------------------------------------------------------------------------------
527+
QUERY PLAN
528+
-----------------------------------------------------
525529
Custom Scan (DecompressChunk) on _hyper_11_12_chunk
526-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
527-
Index Cond: (c_bool = true)
530+
-> Seq Scan on compress_hyper_12_13_chunk
531+
Filter: c_bool
528532
(3 rows)
529533

530534
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_bool = true;
531-
QUERY PLAN
532-
----------------------------------------------------------------------------------------------------------------------
535+
QUERY PLAN
536+
-----------------------------------------------------
533537
Custom Scan (DecompressChunk) on _hyper_11_12_chunk
534-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
535-
Index Cond: (c_bool = true)
538+
-> Seq Scan on compress_hyper_12_13_chunk
539+
Filter: c_bool
536540
(3 rows)
537541

538542
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_bool = false;
539-
QUERY PLAN
540-
----------------------------------------------------------------------------------------------------------------------
543+
QUERY PLAN
544+
-----------------------------------------------------
541545
Custom Scan (DecompressChunk) on _hyper_11_12_chunk
542-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
543-
Index Cond: (c_bool = false)
546+
-> Seq Scan on compress_hyper_12_13_chunk
547+
Filter: (NOT c_bool)
544548
(3 rows)
545549

546550
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE NOT c_bool;
547-
QUERY PLAN
548-
----------------------------------------------------------------------------------------------------------------------
551+
QUERY PLAN
552+
-----------------------------------------------------
549553
Custom Scan (DecompressChunk) on _hyper_11_12_chunk
550-
-> Index Scan using compress_hyper_12_13_chunk_c_date_c_time_c_timetz_c_timesta_idx on compress_hyper_12_13_chunk
551-
Index Cond: (c_bool = false)
554+
-> Seq Scan on compress_hyper_12_13_chunk
555+
Filter: (NOT c_bool)
552556
(3 rows)
553557

554558
-- current_query() is not a sqlvaluefunction and volatile so should not be pushed down
@@ -574,3 +578,4 @@ LATERAL(
574578
--
575579
(1 row)
576580

581+
DROP TABLE svf_pushdown;

tsl/test/sql/compression_qualpushdown.sql

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
-- Please see the included NOTICE for copyright information and
33
-- LICENSE-TIMESCALE for a copy of the license.
44

5+
set max_parallel_workers_per_gather = 0;
6+
57
-- qual pushdown tests for decompresschunk ---
68
-- Test qual pushdown with ints
79
CREATE TABLE meta (device_id INT PRIMARY KEY);
@@ -119,6 +121,7 @@ EXPLAIN (costs off) SELECT * FROM pushdown_relabel WHERE dev_vc = 'varchar';
119121
EXPLAIN (costs off) SELECT * FROM pushdown_relabel WHERE dev_c = 'char';
120122
EXPLAIN (costs off) SELECT * FROM pushdown_relabel WHERE dev_vc = 'varchar' AND dev_c = 'char';
121123
EXPLAIN (costs off) SELECT * FROM pushdown_relabel WHERE dev_vc = 'varchar'::char(10) AND dev_c = 'char'::varchar;
124+
RESET enable_seqscan;
122125

123126
-- github issue #5286
124127
CREATE TABLE deleteme AS
@@ -134,6 +137,7 @@ ALTER TABLE deleteme SET (
134137
);
135138

136139
SELECT compress_chunk(i) FROM show_chunks('deleteme') i;
140+
VACUUM ANALYZE deleteme;
137141
EXPLAIN (costs off) SELECT sum(data) FROM deleteme WHERE segment::text like '%4%';
138142
EXPLAIN (costs off) SELECT sum(data) FROM deleteme WHERE '4' = segment::text;
139143

@@ -161,6 +165,7 @@ ALTER TABLE svf_pushdown SET (timescaledb.compress,timescaledb.compress_segmentb
161165

162166
INSERT INTO svf_pushdown SELECT '2020-01-01';
163167
SELECT compress_chunk(show_chunks('svf_pushdown'));
168+
VACUUM ANALYZE svf_pushdown;
164169

165170
-- constraints should be pushed down into scan below decompresschunk in all cases
166171
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_date = CURRENT_DATE;
@@ -196,3 +201,4 @@ LATERAL(
196201
EXISTS (SELECT FROM meta) LIMIT 1
197202
) l;
198203

204+
DROP TABLE svf_pushdown;

0 commit comments

Comments
 (0)