1
1
-- This file and its contents are licensed under the Timescale License.
2
2
-- Please see the included NOTICE for copyright information and
3
3
-- LICENSE-TIMESCALE for a copy of the license.
4
+ set max_parallel_workers_per_gather = 0;
4
5
-- qual pushdown tests for decompresschunk ---
5
6
-- Test qual pushdown with ints
6
7
CREATE TABLE meta (device_id INT PRIMARY KEY);
@@ -268,6 +269,7 @@ EXPLAIN (costs off) SELECT * FROM pushdown_relabel WHERE dev_vc = 'varchar'::cha
268
269
Filter: ((dev_vc)::bpchar = 'varchar '::character(10))
269
270
(4 rows)
270
271
272
+ RESET enable_seqscan;
271
273
-- github issue #5286
272
274
CREATE TABLE deleteme AS
273
275
SELECT generate_series AS timestamp, 1 AS segment, 0 AS data
@@ -292,6 +294,7 @@ SELECT compress_chunk(i) FROM show_chunks('deleteme') i;
292
294
_timescaledb_internal._hyper_7_8_chunk
293
295
(1 row)
294
296
297
+ VACUUM ANALYZE deleteme;
295
298
EXPLAIN (costs off) SELECT sum(data) FROM deleteme WHERE segment::text like '%4%';
296
299
QUERY PLAN
297
300
---------------------------------------------------------
@@ -368,95 +371,96 @@ SELECT compress_chunk(show_chunks('svf_pushdown'));
368
371
_timescaledb_internal._hyper_11_12_chunk
369
372
(1 row)
370
373
374
+ VACUUM ANALYZE svf_pushdown;
371
375
-- constraints should be pushed down into scan below decompresschunk in all cases
372
376
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_date = CURRENT_DATE;
373
- QUERY PLAN
374
- ----------------------------------------------------------------------------------------------------------------------------
377
+ QUERY PLAN
378
+ -----------------------------------------------------------
375
379
Custom Scan (ChunkAppend) on svf_pushdown
376
380
Chunks excluded during startup: 0
377
381
-> 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)
380
384
(5 rows)
381
385
382
386
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timetz = CURRENT_TIME;
383
- QUERY PLAN
384
- ----------------------------------------------------------------------------------------------------------------------------
387
+ QUERY PLAN
388
+ -----------------------------------------------------------
385
389
Custom Scan (ChunkAppend) on svf_pushdown
386
390
Chunks excluded during startup: 0
387
391
-> 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)
390
394
(5 rows)
391
395
392
396
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timetz = CURRENT_TIME(1);
393
- QUERY PLAN
394
- ----------------------------------------------------------------------------------------------------------------------------
397
+ QUERY PLAN
398
+ -----------------------------------------------------------
395
399
Custom Scan (ChunkAppend) on svf_pushdown
396
400
Chunks excluded during startup: 0
397
401
-> 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))
400
404
(5 rows)
401
405
402
406
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = CURRENT_TIMESTAMP;
403
- QUERY PLAN
404
- ----------------------------------------------------------------------------------------------------------------------------
407
+ QUERY PLAN
408
+ -----------------------------------------------------------
405
409
Custom Scan (ChunkAppend) on svf_pushdown
406
410
Chunks excluded during startup: 0
407
411
-> 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)
410
414
(5 rows)
411
415
412
416
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = CURRENT_TIMESTAMP(1);
413
- QUERY PLAN
414
- ----------------------------------------------------------------------------------------------------------------------------
417
+ QUERY PLAN
418
+ ------------------------------------------------------------
415
419
Custom Scan (ChunkAppend) on svf_pushdown
416
420
Chunks excluded during startup: 0
417
421
-> 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))
420
424
(5 rows)
421
425
422
426
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_time = LOCALTIME;
423
- QUERY PLAN
424
- ----------------------------------------------------------------------------------------------------------------------------
427
+ QUERY PLAN
428
+ -----------------------------------------------------------
425
429
Custom Scan (ChunkAppend) on svf_pushdown
426
430
Chunks excluded during startup: 0
427
431
-> 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)
430
434
(5 rows)
431
435
432
436
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_time = LOCALTIME(1);
433
- QUERY PLAN
434
- ----------------------------------------------------------------------------------------------------------------------------
437
+ QUERY PLAN
438
+ -----------------------------------------------------------
435
439
Custom Scan (ChunkAppend) on svf_pushdown
436
440
Chunks excluded during startup: 0
437
441
-> 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))
440
444
(5 rows)
441
445
442
446
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = LOCALTIMESTAMP;
443
- QUERY PLAN
444
- ----------------------------------------------------------------------------------------------------------------------------
447
+ QUERY PLAN
448
+ -----------------------------------------------------------
445
449
Custom Scan (ChunkAppend) on svf_pushdown
446
450
Chunks excluded during startup: 0
447
451
-> 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)
450
454
(5 rows)
451
455
452
456
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_timestamp = LOCALTIMESTAMP(1);
453
- QUERY PLAN
454
- ----------------------------------------------------------------------------------------------------------------------------
457
+ QUERY PLAN
458
+ -----------------------------------------------------------
455
459
Custom Scan (ChunkAppend) on svf_pushdown
456
460
Chunks excluded during startup: 0
457
461
-> 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))
460
464
(5 rows)
461
465
462
466
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;
520
524
(5 rows)
521
525
522
526
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_bool;
523
- QUERY PLAN
524
- ----------------------------------------------------------------------------------------------------------------------
527
+ QUERY PLAN
528
+ -----------------------------------------------------
525
529
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
528
532
(3 rows)
529
533
530
534
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_bool = true;
531
- QUERY PLAN
532
- ----------------------------------------------------------------------------------------------------------------------
535
+ QUERY PLAN
536
+ -----------------------------------------------------
533
537
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
536
540
(3 rows)
537
541
538
542
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE c_bool = false;
539
- QUERY PLAN
540
- ----------------------------------------------------------------------------------------------------------------------
543
+ QUERY PLAN
544
+ -----------------------------------------------------
541
545
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 )
544
548
(3 rows)
545
549
546
550
EXPLAIN (costs off) SELECT * FROM svf_pushdown WHERE NOT c_bool;
547
- QUERY PLAN
548
- ----------------------------------------------------------------------------------------------------------------------
551
+ QUERY PLAN
552
+ -----------------------------------------------------
549
553
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 )
552
556
(3 rows)
553
557
554
558
-- current_query() is not a sqlvaluefunction and volatile so should not be pushed down
@@ -574,3 +578,4 @@ LATERAL(
574
578
--
575
579
(1 row)
576
580
581
+ DROP TABLE svf_pushdown;
0 commit comments