timescaledb/tsl/test/sql/include/skip_scan_query_ht.sql
Sven Klemm 8fd4ecbdd9 Fix SkipScan for IndexPaths without pathkeys
The SkipScan code assumed IndexPaths on ordered indexes always
have pathkeys which is not true when the pathkeys are not useful
for the query, leading to a segfault for those queries.
2021-04-22 14:06:25 +02:00

28 lines
1.0 KiB
SQL

-- This file and its contents are licensed under the Timescale License.
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
CREATE INDEX ON :TABLE(dev);
CREATE INDEX ON :TABLE(time);
-- SkipScan with ordered append
:PREFIX SELECT DISTINCT ON (time) time FROM :TABLE ORDER BY time;
--baseline query with skipscan
:PREFIX SELECT DISTINCT ON (dev) dev, dev_name FROM :TABLE;
-- compression doesnt prevent skipscan
SELECT compress_chunk('_timescaledb_internal._hyper_1_1_chunk');
:PREFIX SELECT DISTINCT ON (dev) dev, dev_name FROM :TABLE;
SELECT decompress_chunk('_timescaledb_internal._hyper_1_1_chunk');
--baseline query with skipscan
:PREFIX SELECT DISTINCT ON (dev) dev, dev_name FROM :TABLE;
-- partial indexes don't prevent skipscan
DROP INDEX _timescaledb_internal._hyper_1_1_chunk_skip_scan_ht_dev_idx;
:PREFIX SELECT DISTINCT ON (dev) dev, dev_name FROM :TABLE;
-- IndexPath without pathkeys doesnt use SkipScan
EXPLAIN (costs off, timing off, summary off) SELECT DISTINCT 1 FROM pg_rewrite;