mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-28 09:46:44 +08:00
The recently added test for hypertable detection used compression which is not available in ApacheOnly tests so we move that test to regresscheck-t. Additionally we move the other test in plan_hypertable_cache to plan_expand_hypertable to reduce the number of tests.
59 lines
2.0 KiB
MySQL
59 lines
2.0 KiB
MySQL
-- 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.
|
|
|
|
\set PREFIX 'EXPLAIN (costs off) '
|
|
\ir include/plan_expand_hypertable_load.sql
|
|
\ir include/plan_expand_hypertable_query.sql
|
|
\ir include/plan_expand_hypertable_chunks_in_query.sql
|
|
|
|
\set ECHO errors
|
|
\set TEST_BASE_NAME plan_expand_hypertable
|
|
SELECT format('include/%s_load.sql', :'TEST_BASE_NAME') as "TEST_LOAD_NAME",
|
|
format('include/%s_query.sql', :'TEST_BASE_NAME') as "TEST_QUERY_NAME",
|
|
format('%s/results/%s_results_optimized.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_OPTIMIZED",
|
|
format('%s/results/%s_results_unoptimized.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_UNOPTIMIZED"
|
|
\gset
|
|
SELECT format('\! diff -u --label "Unoptimized result" --label "Optimized result" %s %s', :'TEST_RESULTS_UNOPTIMIZED', :'TEST_RESULTS_OPTIMIZED') as "DIFF_CMD"
|
|
\gset
|
|
|
|
-- run queries with optimization on and off and diff results
|
|
\set PREFIX ''
|
|
\o :TEST_RESULTS_OPTIMIZED
|
|
SET timescaledb.enable_optimizations TO true;
|
|
\ir :TEST_QUERY_NAME
|
|
\o
|
|
\o :TEST_RESULTS_UNOPTIMIZED
|
|
SET timescaledb.enable_optimizations TO false;
|
|
\ir :TEST_QUERY_NAME
|
|
\o
|
|
|
|
:DIFF_CMD
|
|
\set ECHO queries
|
|
|
|
RESET timescaledb.enable_optimizations;
|
|
-- test hypertable classification when hypertable is not in cache
|
|
-- https://github.com/timescale/timescaledb/issues/1832
|
|
|
|
\set PREFIX 'EXPLAIN (costs off)'
|
|
|
|
CREATE TABLE test (a int, time timestamptz NOT NULL);
|
|
SELECT create_hypertable('public.test', 'time');
|
|
INSERT INTO test SELECT i, '2020-04-01'::date-10-i from generate_series(1,20) i;
|
|
|
|
CREATE OR REPLACE FUNCTION test_f(_ts timestamptz)
|
|
RETURNS SETOF test LANGUAGE SQL STABLE PARALLEL SAFE
|
|
AS $f$
|
|
SELECT DISTINCT ON (a) * FROM test WHERE time >= _ts ORDER BY a, time DESC
|
|
$f$;
|
|
|
|
:PREFIX SELECT * FROM test_f(now());
|
|
|
|
-- create new session
|
|
\c
|
|
|
|
-- plan output should be identical to previous session
|
|
:PREFIX SELECT * FROM test_f(now());
|
|
|
|
\qecho '--TEST END--'
|