Skip to content

Commit

Permalink
PG16: Fix transparent decompression output tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Nov 3, 2023
1 parent 187b124 commit b4bb3a0
Show file tree
Hide file tree
Showing 12 changed files with 542 additions and 235 deletions.
26 changes: 13 additions & 13 deletions tsl/test/expected/transparent_decompression-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ LIMIT 10;
Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device_id
Sort Method: top-N heapsort
-> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1800 loops=1)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_5_15_chunk (actual rows=5 loops=1)
-> Sort (never executed)
Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device_id
Expand All @@ -1210,7 +1210,7 @@ LIMIT 10;
-> Sort (never executed)
Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device_id
-> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_5_16_chunk (never executed)
(19 rows)

Expand Down Expand Up @@ -1644,7 +1644,7 @@ ORDER BY time,
Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device_id
Sort Method: quicksort
-> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=2520 loops=1)
Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
Vectorized Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
-> Seq Scan on compress_hyper_5_16_chunk (actual rows=5 loops=1)
Filter: (_ts_meta_max_3 > ('2000-01-08'::cstring)::timestamp with time zone)
(15 rows)
Expand Down Expand Up @@ -5015,19 +5015,19 @@ LIMIT 10;
Sort Key: _hyper_2_4_chunk."time", _hyper_2_4_chunk.device_id
Sort Method: top-N heapsort
-> Custom Scan (DecompressChunk) on _hyper_2_4_chunk (actual rows=360 loops=1)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_6_17_chunk (actual rows=1 loops=1)
-> Sort (actual rows=6 loops=1)
Sort Key: _hyper_2_5_chunk."time", _hyper_2_5_chunk.device_id
Sort Method: top-N heapsort
-> Custom Scan (DecompressChunk) on _hyper_2_5_chunk (actual rows=1080 loops=1)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_6_18_chunk (actual rows=3 loops=1)
-> Sort (actual rows=3 loops=1)
Sort Key: _hyper_2_6_chunk."time", _hyper_2_6_chunk.device_id
Sort Method: top-N heapsort
-> Custom Scan (DecompressChunk) on _hyper_2_6_chunk (actual rows=360 loops=1)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_6_19_chunk (actual rows=1 loops=1)
-> Merge Append (never executed)
Sort Key: _hyper_2_7_chunk."time", _hyper_2_7_chunk.device_id
Expand All @@ -5054,12 +5054,12 @@ LIMIT 10;
-> Sort (never executed)
Sort Key: _hyper_2_10_chunk."time", _hyper_2_10_chunk.device_id
-> Custom Scan (DecompressChunk) on _hyper_2_10_chunk (never executed)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_6_20_chunk (never executed)
-> Sort (never executed)
Sort Key: _hyper_2_11_chunk."time", _hyper_2_11_chunk.device_id
-> Custom Scan (DecompressChunk) on _hyper_2_11_chunk (never executed)
Filter: ("time" < now())
Vectorized Filter: ("time" < now())
-> Seq Scan on compress_hyper_6_21_chunk (never executed)
-> Sort (never executed)
Sort Key: _hyper_2_12_chunk."time", _hyper_2_12_chunk.device_id
Expand Down Expand Up @@ -5719,23 +5719,23 @@ ORDER BY time,
Sort Key: _hyper_2_4_chunk."time", _hyper_2_4_chunk.device_id
Sort Method: quicksort
-> Custom Scan (DecompressChunk) on _hyper_2_4_chunk (actual rows=0 loops=1)
Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
Vectorized Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
-> Seq Scan on compress_hyper_6_17_chunk (actual rows=0 loops=1)
Filter: (_ts_meta_max_3 > ('2000-01-08'::cstring)::timestamp with time zone)
Rows Removed by Filter: 1
-> Sort (actual rows=0 loops=1)
Sort Key: _hyper_2_5_chunk."time", _hyper_2_5_chunk.device_id
Sort Method: quicksort
-> Custom Scan (DecompressChunk) on _hyper_2_5_chunk (actual rows=0 loops=1)
Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
Vectorized Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
-> Seq Scan on compress_hyper_6_18_chunk (actual rows=0 loops=1)
Filter: (_ts_meta_max_3 > ('2000-01-08'::cstring)::timestamp with time zone)
Rows Removed by Filter: 3
-> Sort (actual rows=0 loops=1)
Sort Key: _hyper_2_6_chunk."time", _hyper_2_6_chunk.device_id
Sort Method: quicksort
-> Custom Scan (DecompressChunk) on _hyper_2_6_chunk (actual rows=0 loops=1)
Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
Vectorized Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
-> Seq Scan on compress_hyper_6_19_chunk (actual rows=0 loops=1)
Filter: (_ts_meta_max_3 > ('2000-01-08'::cstring)::timestamp with time zone)
Rows Removed by Filter: 1
Expand Down Expand Up @@ -5773,14 +5773,14 @@ ORDER BY time,
Sort Key: _hyper_2_10_chunk."time", _hyper_2_10_chunk.device_id
Sort Method: quicksort
-> Custom Scan (DecompressChunk) on _hyper_2_10_chunk (actual rows=504 loops=1)
Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
Vectorized Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
-> Seq Scan on compress_hyper_6_20_chunk (actual rows=1 loops=1)
Filter: (_ts_meta_max_3 > ('2000-01-08'::cstring)::timestamp with time zone)
-> Sort (actual rows=1512 loops=1)
Sort Key: _hyper_2_11_chunk."time", _hyper_2_11_chunk.device_id
Sort Method: quicksort
-> Custom Scan (DecompressChunk) on _hyper_2_11_chunk (actual rows=1512 loops=1)
Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
Vectorized Filter: ("time" > ('2000-01-08'::cstring)::timestamp with time zone)
-> Seq Scan on compress_hyper_6_21_chunk (actual rows=3 loops=1)
Filter: (_ts_meta_max_3 > ('2000-01-08'::cstring)::timestamp with time zone)
-> Sort (actual rows=504 loops=1)
Expand Down
101 changes: 101 additions & 0 deletions tsl/test/expected/transparent_decompression_join_index-14.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
-- 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.
\c :TEST_DBNAME :ROLE_SUPERUSER
-- github issue 5585
create table test (
time timestamptz not null,
a varchar(255) not null,
b int,
c int
);
SELECT create_hypertable('test', 'time');
WARNING: column type "character varying" used for "a" does not follow best practices
create_hypertable
-------------------
(1,public,test,t)
(1 row)

insert into test values
('2020-01-01 00:00'::timestamptz, 'lat', 1, 2),
('2020-01-01 00:01'::timestamptz, 'lat', 1, 2),
('2020-01-01 00:01'::timestamptz, 'lat', 2, 2),
('2020-01-01 00:03'::timestamptz, 'lat', 1, 2),
('2020-01-01 00:01'::timestamptz, 'lon', 1, 2);
create table test_copy as select * from test;
-- compress the chunk
alter table test set (timescaledb.compress, timescaledb.compress_segmentby='a, b');
select compress_chunk(show_chunks('test'));
compress_chunk
----------------------------------------
_timescaledb_internal._hyper_1_1_chunk
(1 row)

-- force an index scan
set enable_seqscan = 'off';
-- disable jit to avoid test flakiness
set jit = off;
explain (costs off) with query_params as (
select distinct a, b
from test_copy
where test_copy.a IN ('lat', 'lon')
and test_copy.b IN (1)
)
select
test.time,
test.a = q.a as "this should never be false",
test.a,
test.b,
test.c,
q.*
from
test inner join query_params q
on q.a = test.a and q.b = test.b
where test.time between '2020-01-01 00:00' and '2020-01-01 00:02'
order by test.time;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Sort Key: _hyper_1_1_chunk."time"
-> Nested Loop
-> Unique
-> Sort
Sort Key: test_copy.a
-> Seq Scan on test_copy
Filter: (((a)::text = ANY ('{lat,lon}'::text[])) AND (b = 1))
-> Custom Scan (DecompressChunk) on _hyper_1_1_chunk
Vectorized Filter: (("time" >= 'Wed Jan 01 00:00:00 2020 PST'::timestamp with time zone) AND ("time" <= 'Wed Jan 01 00:02:00 2020 PST'::timestamp with time zone))
-> Index Scan using compress_hyper_2_2_chunk__compressed_hypertable_2_a_b__ts_meta_ on compress_hyper_2_2_chunk
Index Cond: ((a = (test_copy.a)::text) AND (b = test_copy.b))
Filter: ((_ts_meta_max_1 >= 'Wed Jan 01 00:00:00 2020 PST'::timestamp with time zone) AND (_ts_meta_min_1 <= 'Wed Jan 01 00:02:00 2020 PST'::timestamp with time zone))
(13 rows)

with query_params as (
select distinct a, b
from test_copy
where test_copy.a IN ('lat', 'lon')
and test_copy.b IN (1)
)
select
test.time,
test.a = q.a as "this should never be false",
test.a,
test.b,
test.c,
q.*
from
test inner join query_params q
on q.a = test.a and q.b = test.b
where test.time between '2020-01-01 00:00' and '2020-01-01 00:02'
order by test.time;
time | this should never be false | a | b | c | a | b
------------------------------+----------------------------+-----+---+---+-----+---
Wed Jan 01 00:00:00 2020 PST | t | lat | 1 | 2 | lat | 1
Wed Jan 01 00:01:00 2020 PST | t | lat | 1 | 2 | lat | 1
Wed Jan 01 00:01:00 2020 PST | t | lon | 1 | 2 | lon | 1
(3 rows)

reset enable_seqscan;
reset jit;
drop table test;
drop table test_copy;
101 changes: 101 additions & 0 deletions tsl/test/expected/transparent_decompression_join_index-15.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
-- 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.
\c :TEST_DBNAME :ROLE_SUPERUSER
-- github issue 5585
create table test (
time timestamptz not null,
a varchar(255) not null,
b int,
c int
);
SELECT create_hypertable('test', 'time');
WARNING: column type "character varying" used for "a" does not follow best practices
create_hypertable
-------------------
(1,public,test,t)
(1 row)

insert into test values
('2020-01-01 00:00'::timestamptz, 'lat', 1, 2),
('2020-01-01 00:01'::timestamptz, 'lat', 1, 2),
('2020-01-01 00:01'::timestamptz, 'lat', 2, 2),
('2020-01-01 00:03'::timestamptz, 'lat', 1, 2),
('2020-01-01 00:01'::timestamptz, 'lon', 1, 2);
create table test_copy as select * from test;
-- compress the chunk
alter table test set (timescaledb.compress, timescaledb.compress_segmentby='a, b');
select compress_chunk(show_chunks('test'));
compress_chunk
----------------------------------------
_timescaledb_internal._hyper_1_1_chunk
(1 row)

-- force an index scan
set enable_seqscan = 'off';
-- disable jit to avoid test flakiness
set jit = off;
explain (costs off) with query_params as (
select distinct a, b
from test_copy
where test_copy.a IN ('lat', 'lon')
and test_copy.b IN (1)
)
select
test.time,
test.a = q.a as "this should never be false",
test.a,
test.b,
test.c,
q.*
from
test inner join query_params q
on q.a = test.a and q.b = test.b
where test.time between '2020-01-01 00:00' and '2020-01-01 00:02'
order by test.time;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Sort Key: _hyper_1_1_chunk."time"
-> Nested Loop
-> Unique
-> Sort
Sort Key: test_copy.a
-> Seq Scan on test_copy
Filter: (((a)::text = ANY ('{lat,lon}'::text[])) AND (b = 1))
-> Custom Scan (DecompressChunk) on _hyper_1_1_chunk
Vectorized Filter: (("time" >= 'Wed Jan 01 00:00:00 2020 PST'::timestamp with time zone) AND ("time" <= 'Wed Jan 01 00:02:00 2020 PST'::timestamp with time zone))
-> Index Scan using compress_hyper_2_2_chunk__compressed_hypertable_2_a_b__ts_meta_ on compress_hyper_2_2_chunk
Index Cond: ((a = (test_copy.a)::text) AND (b = test_copy.b))
Filter: ((_ts_meta_max_1 >= 'Wed Jan 01 00:00:00 2020 PST'::timestamp with time zone) AND (_ts_meta_min_1 <= 'Wed Jan 01 00:02:00 2020 PST'::timestamp with time zone))
(13 rows)

with query_params as (
select distinct a, b
from test_copy
where test_copy.a IN ('lat', 'lon')
and test_copy.b IN (1)
)
select
test.time,
test.a = q.a as "this should never be false",
test.a,
test.b,
test.c,
q.*
from
test inner join query_params q
on q.a = test.a and q.b = test.b
where test.time between '2020-01-01 00:00' and '2020-01-01 00:02'
order by test.time;
time | this should never be false | a | b | c | a | b
------------------------------+----------------------------+-----+---+---+-----+---
Wed Jan 01 00:00:00 2020 PST | t | lat | 1 | 2 | lat | 1
Wed Jan 01 00:01:00 2020 PST | t | lat | 1 | 2 | lat | 1
Wed Jan 01 00:01:00 2020 PST | t | lon | 1 | 2 | lon | 1
(3 rows)

reset enable_seqscan;
reset jit;
drop table test;
drop table test_copy;
Loading

0 comments on commit b4bb3a0

Please sign in to comment.