mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 18:13:18 +08:00
Make plan_hypertable_inline test output PG version specific
PG13 changes the relation name aliasing in EXPLAIN output making explain output different from previous PG versions.
This commit is contained in:
parent
b5a9d33ef3
commit
8b744f2cc4
149
test/expected/plan_hypertable_inline-13.out
Normal file
149
test/expected/plan_hypertable_inline-13.out
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
-- This file and its contents are licensed under the Apache License 2.0.
|
||||||
|
-- Please see the included NOTICE for copyright information and
|
||||||
|
-- LICENSE-APACHE for a copy of the license.
|
||||||
|
-- test hypertable classification when query is in an inlineable function
|
||||||
|
\set PREFIX 'EXPLAIN (costs off)'
|
||||||
|
CREATE TABLE test (a int, b bigint NOT NULL);
|
||||||
|
SELECT create_hypertable('public.test', 'b', chunk_time_interval=>10);
|
||||||
|
create_hypertable
|
||||||
|
-------------------
|
||||||
|
(1,public,test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO test SELECT i, i FROM generate_series(1, 20) i;
|
||||||
|
CREATE OR REPLACE FUNCTION test_f(_ts bigint)
|
||||||
|
RETURNS SETOF test LANGUAGE SQL STABLE
|
||||||
|
as $f$
|
||||||
|
SELECT DISTINCT ON (a) * FROM test WHERE b >= _ts AND b <= _ts + 2
|
||||||
|
$f$;
|
||||||
|
-- plans must be the same in both cases
|
||||||
|
-- specifically, the first plan should not contain the parent hypertable
|
||||||
|
-- as that is a sign the pruning was not done successfully
|
||||||
|
:PREFIX SELECT * FROM test_f(5);
|
||||||
|
QUERY PLAN
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Unique
|
||||||
|
-> Sort
|
||||||
|
Sort Key: _hyper_1_1_chunk.a
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk
|
||||||
|
Index Cond: ((b >= '5'::bigint) AND (b <= '7'::bigint))
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
|
:PREFIX SELECT DISTINCT ON (a) * FROM test WHERE b >= 5 AND b <= 5 + 2;
|
||||||
|
QUERY PLAN
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Unique
|
||||||
|
-> Sort
|
||||||
|
Sort Key: _hyper_1_1_chunk.a
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk
|
||||||
|
Index Cond: ((b >= 5) AND (b <= 7))
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
|
-- test with FOR UPDATE
|
||||||
|
CREATE OR REPLACE FUNCTION test_f(_ts bigint)
|
||||||
|
RETURNS SETOF test LANGUAGE SQL STABLE
|
||||||
|
as $f$
|
||||||
|
SELECT * FROM test WHERE b >= _ts AND b <= _ts + 2 FOR UPDATE
|
||||||
|
$f$;
|
||||||
|
-- pruning should not be done by TimescaleDb in this case
|
||||||
|
-- specifically, the parent hypertable must exist in the output plan
|
||||||
|
:PREFIX SELECT * FROM test_f(5);
|
||||||
|
QUERY PLAN
|
||||||
|
-------------------------------------------------------------------------------------------
|
||||||
|
Subquery Scan on test_f
|
||||||
|
-> LockRows
|
||||||
|
-> Append
|
||||||
|
-> Seq Scan on test test_1
|
||||||
|
Filter: ((b >= '5'::bigint) AND (b <= '7'::bigint))
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk test_2
|
||||||
|
Index Cond: ((b >= '5'::bigint) AND (b <= '7'::bigint))
|
||||||
|
(7 rows)
|
||||||
|
|
||||||
|
:PREFIX SELECT * FROM test WHERE b >= 5 AND b <= 5 + 2 FOR UPDATE;
|
||||||
|
QUERY PLAN
|
||||||
|
-------------------------------------------------------------------------------------
|
||||||
|
LockRows
|
||||||
|
-> Append
|
||||||
|
-> Seq Scan on test test_1
|
||||||
|
Filter: ((b >= 5) AND (b <= 7))
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk test_2
|
||||||
|
Index Cond: ((b >= 5) AND (b <= 7))
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
-- test with CTE
|
||||||
|
-- these cases are just to make sure we're everything is alright with
|
||||||
|
-- the way we identify hypertables to prune chunks - we abuse ctename
|
||||||
|
-- for this purpose. So double-check if we're not breaking plans
|
||||||
|
-- with CTEs here.
|
||||||
|
CREATE OR REPLACE FUNCTION test_f(_ts bigint)
|
||||||
|
RETURNS SETOF test LANGUAGE SQL STABLE
|
||||||
|
as $f$
|
||||||
|
WITH ct AS MATERIALIZED (
|
||||||
|
SELECT DISTINCT ON (a) * FROM test WHERE b >= _ts AND b <= _ts + 2
|
||||||
|
)
|
||||||
|
SELECT * FROM ct
|
||||||
|
$f$;
|
||||||
|
:PREFIX SELECT * FROM test_f(5);
|
||||||
|
QUERY PLAN
|
||||||
|
--------------------------------------------------------------------------------------
|
||||||
|
CTE Scan on ct
|
||||||
|
CTE ct
|
||||||
|
-> Unique
|
||||||
|
-> Sort
|
||||||
|
Sort Key: _hyper_1_1_chunk.a
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk
|
||||||
|
Index Cond: ((b >= '5'::bigint) AND (b <= '7'::bigint))
|
||||||
|
(7 rows)
|
||||||
|
|
||||||
|
:PREFIX
|
||||||
|
WITH ct AS MATERIALIZED (
|
||||||
|
SELECT DISTINCT ON (a) * FROM test WHERE b >= 5 AND b <= 5 + 2
|
||||||
|
)
|
||||||
|
SELECT * FROM ct;
|
||||||
|
QUERY PLAN
|
||||||
|
--------------------------------------------------------------------------------------
|
||||||
|
CTE Scan on ct
|
||||||
|
CTE ct
|
||||||
|
-> Unique
|
||||||
|
-> Sort
|
||||||
|
Sort Key: _hyper_1_1_chunk.a
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk
|
||||||
|
Index Cond: ((b >= 5) AND (b <= 7))
|
||||||
|
(7 rows)
|
||||||
|
|
||||||
|
-- CTE within CTE
|
||||||
|
:PREFIX
|
||||||
|
WITH ct AS MATERIALIZED (
|
||||||
|
SELECT * FROM test_f(5)
|
||||||
|
)
|
||||||
|
SELECT * FROM ct;
|
||||||
|
QUERY PLAN
|
||||||
|
----------------------------------------------------------------------------------------------
|
||||||
|
CTE Scan on ct
|
||||||
|
CTE ct
|
||||||
|
-> CTE Scan on ct ct_1
|
||||||
|
CTE ct
|
||||||
|
-> Unique
|
||||||
|
-> Sort
|
||||||
|
Sort Key: _hyper_1_1_chunk.a
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk
|
||||||
|
Index Cond: ((b >= '5'::bigint) AND (b <= '7'::bigint))
|
||||||
|
(9 rows)
|
||||||
|
|
||||||
|
-- CTE within NO MATERIALIZED CTE
|
||||||
|
:PREFIX
|
||||||
|
WITH ct AS NOT MATERIALIZED (
|
||||||
|
SELECT * FROM test_f(5)
|
||||||
|
)
|
||||||
|
SELECT * FROM ct;
|
||||||
|
QUERY PLAN
|
||||||
|
--------------------------------------------------------------------------------------
|
||||||
|
CTE Scan on ct
|
||||||
|
CTE ct
|
||||||
|
-> Unique
|
||||||
|
-> Sort
|
||||||
|
Sort Key: _hyper_1_1_chunk.a
|
||||||
|
-> Index Scan using _hyper_1_1_chunk_test_b_idx on _hyper_1_1_chunk
|
||||||
|
Index Cond: ((b >= '5'::bigint) AND (b <= '7'::bigint))
|
||||||
|
(7 rows)
|
||||||
|
|
1
test/sql/.gitignore
vendored
1
test/sql/.gitignore
vendored
@ -18,6 +18,7 @@
|
|||||||
/plan_hashagg_optimized-*.sql
|
/plan_hashagg_optimized-*.sql
|
||||||
/plan_hashagg-*.sql
|
/plan_hashagg-*.sql
|
||||||
/plan_hypertable_cache-*.sql
|
/plan_hypertable_cache-*.sql
|
||||||
|
/plan_hypertable_inline-*.sql
|
||||||
/plan_ordered_append-*.sql
|
/plan_ordered_append-*.sql
|
||||||
/query-*.sql
|
/query-*.sql
|
||||||
/sort_optimization-*.sql
|
/sort_optimization-*.sql
|
||||||
|
@ -47,6 +47,28 @@ set(TEST_FILES
|
|||||||
license.sql
|
license.sql
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(TEST_TEMPLATES
|
||||||
|
agg_bookends.sql.in
|
||||||
|
append.sql.in
|
||||||
|
insert.sql.in
|
||||||
|
chunk_adaptive.sql.in
|
||||||
|
constraint.sql.in
|
||||||
|
copy.sql.in
|
||||||
|
ddl.sql.in
|
||||||
|
delete.sql.in
|
||||||
|
parallel.sql.in
|
||||||
|
partition.sql.in
|
||||||
|
partitionwise.sql.in
|
||||||
|
plan_expand_hypertable.sql.in
|
||||||
|
#hashagg is different in 9.6 and 10 because of hashagg parallelism
|
||||||
|
plan_hashagg.sql.in
|
||||||
|
query.sql.in
|
||||||
|
# Query tests differ in how PostgreSQL deals with projections on partitioned tables.
|
||||||
|
sort_optimization.sql.in
|
||||||
|
sql_query.sql.in
|
||||||
|
update.sql.in
|
||||||
|
)
|
||||||
|
|
||||||
# tests that fail or are unreliable when run in parallel
|
# tests that fail or are unreliable when run in parallel
|
||||||
# bgw tests need to run first otherwise they are flaky
|
# bgw tests need to run first otherwise they are flaky
|
||||||
set(SOLO_TESTS
|
set(SOLO_TESTS
|
||||||
@ -93,33 +115,13 @@ if ((${PG_VERSION_MAJOR} GREATER_EQUAL "12"))
|
|||||||
list(APPEND TEST_FILES
|
list(APPEND TEST_FILES
|
||||||
generated_columns.sql
|
generated_columns.sql
|
||||||
misc.sql
|
misc.sql
|
||||||
plan_hypertable_inline.sql
|
|
||||||
tableam.sql
|
tableam.sql
|
||||||
)
|
)
|
||||||
|
list(APPEND TEST_TEMPLATES
|
||||||
|
plan_hypertable_inline.sql.in
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(TEST_TEMPLATES
|
|
||||||
agg_bookends.sql.in
|
|
||||||
append.sql.in
|
|
||||||
insert.sql.in
|
|
||||||
chunk_adaptive.sql.in
|
|
||||||
constraint.sql.in
|
|
||||||
copy.sql.in
|
|
||||||
ddl.sql.in
|
|
||||||
delete.sql.in
|
|
||||||
parallel.sql.in
|
|
||||||
partition.sql.in
|
|
||||||
partitionwise.sql.in
|
|
||||||
plan_expand_hypertable.sql.in
|
|
||||||
#hashagg is different in 9.6 and 10 because of hashagg parallelism
|
|
||||||
plan_hashagg.sql.in
|
|
||||||
query.sql.in
|
|
||||||
# Query tests differ in how PostgreSQL deals with projections on partitioned tables.
|
|
||||||
sort_optimization.sql.in
|
|
||||||
sql_query.sql.in
|
|
||||||
update.sql.in
|
|
||||||
)
|
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
list(APPEND TEST_TEMPLATES
|
list(APPEND TEST_TEMPLATES
|
||||||
multi_transaction_index.sql.in
|
multi_transaction_index.sql.in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user