timescaledb/test/sql/plan_hypertable_cache.sql.in
Floris van Nee 5c6940d734 Add support for fast pruning of inlined functions
Inlineable functions used to be slow to plan, because the query
preprocessing function could not find the relations inside the
functions, as they haven't been inlined yet at that point.
This commit adds a separate check in the get_relation_info_hook
to optimize pruning of hypertables.
2020-06-04 09:20:58 +02:00

27 lines
877 B
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.
-- 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());