From cb9f74c9349aa2d817643b531b4c4a1d1860e9cb Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Wed, 8 Jan 2025 10:40:39 +0100 Subject: [PATCH] Disable index only scan for ordered append test The test only checks what index is chosen and the choice between index and index only scans generate different plans as a result of external factors such as the platform it executes on. --- .../expected/ordered_append_join-14.out | 526 +++++++++--------- .../expected/ordered_append_join-15.out | 526 +++++++++--------- .../expected/ordered_append_join-16.out | 526 +++++++++--------- .../expected/ordered_append_join-17.out | 526 +++++++++--------- .../shared/sql/ordered_append_join.sql.in | 5 + 5 files changed, 1065 insertions(+), 1044 deletions(-) diff --git a/tsl/test/shared/expected/ordered_append_join-14.out b/tsl/test/shared/expected/ordered_append_join-14.out index 2aa7a9cf3ed..7643127dcd5 100644 --- a/tsl/test/shared/expected/ordered_append_join-14.out +++ b/tsl/test/shared/expected/ordered_append_join-14.out @@ -2,6 +2,10 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. SET timescaledb.enable_now_constify TO FALSE; +-- We disable index only scans to avoid some flakiness. It is not +-- needed for the tests and it is only important which index is +-- picked. +SET enable_indexonlyscan TO FALSE; SELECT format('include/%s.sql', :'TEST_BASE_NAME') as "TEST_QUERY_NAME", format('%s/shared/results/%s_results_uncompressed.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_UNCOMPRESSED", @@ -43,12 +47,12 @@ QUERY PLAN -> Nested Loop (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(12 rows) +(9 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -70,10 +74,10 @@ QUERY PLAN -> Limit (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=2 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(13 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(10 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -88,13 +92,13 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) -(12 rows) +(9 rows) -- test plan with best index is chosen -- this should use time index @@ -107,10 +111,10 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(9 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(6 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -133,13 +137,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(16 rows) +(13 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -162,13 +166,13 @@ QUERY PLAN Order: o."time" Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(16 rows) +(13 rows) -- test startup and runtime exclusion together :PREFIX @@ -191,13 +195,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(16 rows) +(13 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -240,22 +244,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(19 rows) RESET enable_nestloop; -- test JOIN @@ -277,17 +281,17 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=2 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=6 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) -(20 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) +(15 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -308,11 +312,11 @@ QUERY PLAN Merge Cond: (o1."time" = ($0)) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: (device_id = 1) -> Sort (actual rows=1 loops=1) Sort Key: ($0) @@ -322,13 +326,13 @@ QUERY PLAN -> Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -(30 rows) +(24 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -350,22 +354,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -383,22 +387,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -435,22 +439,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -468,22 +472,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -501,22 +505,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -535,22 +539,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -568,22 +572,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -627,21 +631,21 @@ QUERY PLAN -> Nested Loop (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=1 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 1) -(24 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -660,22 +664,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -695,33 +699,33 @@ QUERY PLAN Merge Cond: (o3."time" = o1."time") -> Custom Scan (ChunkAppend) on metrics o3 (actual rows=100 loops=1) Order: o3."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) Index Cond: (device_id = 3) -> Materialize (actual rows=100 loops=1) -> Merge Join (actual rows=100 loops=1) Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(40 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_space' @@ -755,22 +759,22 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(30 rows) +(21 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -794,20 +798,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=2 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(31 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(22 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -843,20 +847,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(27 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(18 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -879,29 +883,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(38 rows) +(29 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -924,29 +928,29 @@ QUERY PLAN Order: o."time" -> Merge Append (actual rows=0 loops=2) Sort Key: o_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=2) Sort Key: o_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (never executed) Sort Key: o_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(38 rows) +(29 rows) -- test startup and runtime exclusion together :PREFIX @@ -969,29 +973,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(38 rows) +(29 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -1015,29 +1019,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -(38 rows) +(29 rows) -- test JOIN -- no exclusion on joined table because quals are not propagated yet @@ -1069,13 +1073,13 @@ QUERY PLAN -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(22 rows) RESET enable_nestloop; -- test JOIN @@ -1099,39 +1103,39 @@ QUERY PLAN Order: o1."time" -> Merge Append (actual rows=2 loops=1) Sort Key: o1_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Merge Append (never executed) Sort Key: o1_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=6 loops=1) Order: o2."time" -> Merge Append (actual rows=6 loops=1) Sort Key: o2_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) -> Merge Append (never executed) Sort Key: o2_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) -> Merge Append (never executed) Sort Key: o2_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) -(54 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) +(39 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -1168,29 +1172,29 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -(51 rows) +(42 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -1221,13 +1225,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -1254,13 +1258,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -1306,13 +1310,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -1339,13 +1343,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -1372,13 +1376,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -1406,13 +1410,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -1439,13 +1443,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -1521,13 +1525,13 @@ QUERY PLAN Filter: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 1) -(21 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -1555,13 +1559,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -1601,13 +1605,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(34 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_compressed' diff --git a/tsl/test/shared/expected/ordered_append_join-15.out b/tsl/test/shared/expected/ordered_append_join-15.out index 057dc48783b..e285da34dfa 100644 --- a/tsl/test/shared/expected/ordered_append_join-15.out +++ b/tsl/test/shared/expected/ordered_append_join-15.out @@ -2,6 +2,10 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. SET timescaledb.enable_now_constify TO FALSE; +-- We disable index only scans to avoid some flakiness. It is not +-- needed for the tests and it is only important which index is +-- picked. +SET enable_indexonlyscan TO FALSE; SELECT format('include/%s.sql', :'TEST_BASE_NAME') as "TEST_QUERY_NAME", format('%s/shared/results/%s_results_uncompressed.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_UNCOMPRESSED", @@ -43,12 +47,12 @@ QUERY PLAN -> Nested Loop (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(12 rows) +(9 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -71,10 +75,10 @@ QUERY PLAN -> Result (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=2 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(14 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(11 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -89,13 +93,13 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) -(12 rows) +(9 rows) -- test plan with best index is chosen -- this should use time index @@ -108,10 +112,10 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(9 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(6 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -135,13 +139,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(17 rows) +(14 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -165,13 +169,13 @@ QUERY PLAN Order: o."time" Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(17 rows) +(14 rows) -- test startup and runtime exclusion together :PREFIX @@ -195,13 +199,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(17 rows) +(14 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -245,22 +249,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(19 rows) RESET enable_nestloop; -- test JOIN @@ -282,18 +286,18 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=2 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Result (actual rows=6 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=6 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) -(21 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) +(16 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -314,11 +318,11 @@ QUERY PLAN Merge Cond: (o1."time" = ($0)) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: (device_id = 1) -> Sort (actual rows=1 loops=1) Sort Key: ($0) @@ -328,13 +332,13 @@ QUERY PLAN -> Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -(30 rows) +(24 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -356,22 +360,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -389,22 +393,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -441,22 +445,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -474,22 +478,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -507,22 +511,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -541,22 +545,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -574,22 +578,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -633,21 +637,21 @@ QUERY PLAN -> Nested Loop (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=1 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 1) -(24 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -666,22 +670,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -701,33 +705,33 @@ QUERY PLAN Merge Cond: (o3."time" = o1."time") -> Custom Scan (ChunkAppend) on metrics o3 (actual rows=100 loops=1) Order: o3."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) Index Cond: (device_id = 3) -> Materialize (actual rows=100 loops=1) -> Merge Join (actual rows=100 loops=1) Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(40 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_space' @@ -761,22 +765,22 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(30 rows) +(21 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -801,20 +805,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=2 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(32 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(23 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -850,20 +854,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(27 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(18 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -887,29 +891,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(39 rows) +(30 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -933,29 +937,29 @@ QUERY PLAN Order: o."time" -> Merge Append (actual rows=0 loops=2) Sort Key: o_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=2) Sort Key: o_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (never executed) Sort Key: o_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(39 rows) +(30 rows) -- test startup and runtime exclusion together :PREFIX @@ -979,29 +983,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(39 rows) +(30 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -1026,29 +1030,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -(39 rows) +(30 rows) -- test JOIN -- no exclusion on joined table because quals are not propagated yet @@ -1080,13 +1084,13 @@ QUERY PLAN -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(22 rows) RESET enable_nestloop; -- test JOIN @@ -1110,19 +1114,19 @@ QUERY PLAN Order: o1."time" -> Merge Append (actual rows=2 loops=1) Sort Key: o1_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Merge Append (never executed) Sort Key: o1_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Result (actual rows=6 loops=1) @@ -1130,20 +1134,20 @@ QUERY PLAN Order: o2."time" -> Merge Append (actual rows=6 loops=1) Sort Key: o2_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) -> Merge Append (never executed) Sort Key: o2_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) -> Merge Append (never executed) Sort Key: o2_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) -(55 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) +(40 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -1180,29 +1184,29 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -(51 rows) +(42 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -1233,13 +1237,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -1266,13 +1270,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -1318,13 +1322,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -1351,13 +1355,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -1384,13 +1388,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -1418,13 +1422,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -1451,13 +1455,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -1533,13 +1537,13 @@ QUERY PLAN Filter: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 1) -(21 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -1567,13 +1571,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -1613,13 +1617,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(34 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_compressed' diff --git a/tsl/test/shared/expected/ordered_append_join-16.out b/tsl/test/shared/expected/ordered_append_join-16.out index 8967a7dea80..9d9382c5ad1 100644 --- a/tsl/test/shared/expected/ordered_append_join-16.out +++ b/tsl/test/shared/expected/ordered_append_join-16.out @@ -2,6 +2,10 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. SET timescaledb.enable_now_constify TO FALSE; +-- We disable index only scans to avoid some flakiness. It is not +-- needed for the tests and it is only important which index is +-- picked. +SET enable_indexonlyscan TO FALSE; SELECT format('include/%s.sql', :'TEST_BASE_NAME') as "TEST_QUERY_NAME", format('%s/shared/results/%s_results_uncompressed.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_UNCOMPRESSED", @@ -43,12 +47,12 @@ QUERY PLAN -> Nested Loop (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(12 rows) +(9 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -71,10 +75,10 @@ QUERY PLAN -> Result (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=2 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(14 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(11 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -89,13 +93,13 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) -(12 rows) +(9 rows) -- test plan with best index is chosen -- this should use time index @@ -108,10 +112,10 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(9 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(6 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -135,13 +139,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(17 rows) +(14 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -165,13 +169,13 @@ QUERY PLAN Order: o."time" Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(17 rows) +(14 rows) -- test startup and runtime exclusion together :PREFIX @@ -195,13 +199,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(17 rows) +(14 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -245,22 +249,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(19 rows) RESET enable_nestloop; -- test JOIN @@ -282,18 +286,18 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=2 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Result (actual rows=6 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=6 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) -(21 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) +(16 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -314,11 +318,11 @@ QUERY PLAN Merge Cond: (o1."time" = ($0)) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: (device_id = 1) -> Sort (actual rows=1 loops=1) Sort Key: ($0) @@ -328,13 +332,13 @@ QUERY PLAN -> Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -(30 rows) +(24 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -356,22 +360,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -389,22 +393,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -441,22 +445,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -474,22 +478,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -507,22 +511,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -541,22 +545,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -574,22 +578,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -633,21 +637,21 @@ QUERY PLAN -> Nested Loop (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=1 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) -(24 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -666,22 +670,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -701,33 +705,33 @@ QUERY PLAN Merge Cond: (o3."time" = o1."time") -> Custom Scan (ChunkAppend) on metrics o3 (actual rows=100 loops=1) Order: o3."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) Index Cond: (device_id = 3) -> Materialize (actual rows=100 loops=1) -> Merge Join (actual rows=100 loops=1) Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(40 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_space' @@ -761,22 +765,22 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(30 rows) +(21 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -801,20 +805,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=2 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(32 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(23 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -850,20 +854,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(27 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(18 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -887,29 +891,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(39 rows) +(30 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -933,29 +937,29 @@ QUERY PLAN Order: o."time" -> Merge Append (actual rows=0 loops=2) Sort Key: o_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=2) Sort Key: o_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (never executed) Sort Key: o_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(39 rows) +(30 rows) -- test startup and runtime exclusion together :PREFIX @@ -979,29 +983,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(39 rows) +(30 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -1026,29 +1030,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -(39 rows) +(30 rows) -- test JOIN -- no exclusion on joined table because quals are not propagated yet @@ -1080,13 +1084,13 @@ QUERY PLAN -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(22 rows) RESET enable_nestloop; -- test JOIN @@ -1110,19 +1114,19 @@ QUERY PLAN Order: o1."time" -> Merge Append (actual rows=2 loops=1) Sort Key: o1_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Merge Append (never executed) Sort Key: o1_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Result (actual rows=6 loops=1) @@ -1130,20 +1134,20 @@ QUERY PLAN Order: o2."time" -> Merge Append (actual rows=6 loops=1) Sort Key: o2_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) -> Merge Append (never executed) Sort Key: o2_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) -> Merge Append (never executed) Sort Key: o2_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) -(55 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) +(40 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -1180,29 +1184,29 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: ("time" IS NOT NULL) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) Index Cond: ("time" IS NOT NULL) -(51 rows) +(42 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -1233,13 +1237,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -1266,13 +1270,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -1318,13 +1322,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -1351,13 +1355,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -1384,13 +1388,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -1418,13 +1422,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -1451,13 +1455,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -1533,13 +1537,13 @@ QUERY PLAN Filter: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) -(21 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -1567,13 +1571,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -1613,13 +1617,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(34 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_compressed' diff --git a/tsl/test/shared/expected/ordered_append_join-17.out b/tsl/test/shared/expected/ordered_append_join-17.out index 96804043a04..03934c9651d 100644 --- a/tsl/test/shared/expected/ordered_append_join-17.out +++ b/tsl/test/shared/expected/ordered_append_join-17.out @@ -2,6 +2,10 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. SET timescaledb.enable_now_constify TO FALSE; +-- We disable index only scans to avoid some flakiness. It is not +-- needed for the tests and it is only important which index is +-- picked. +SET enable_indexonlyscan TO FALSE; SELECT format('include/%s.sql', :'TEST_BASE_NAME') as "TEST_QUERY_NAME", format('%s/shared/results/%s_results_uncompressed.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_UNCOMPRESSED", @@ -43,12 +47,12 @@ QUERY PLAN -> Nested Loop (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(12 rows) +(9 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -71,10 +75,10 @@ QUERY PLAN -> Result (actual rows=2 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=2 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(14 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(11 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -89,13 +93,13 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk (never executed) Index Cond: (device_id = 1) -(12 rows) +(9 rows) -- test plan with best index is chosen -- this should use time index @@ -108,10 +112,10 @@ QUERY PLAN Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(9 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(6 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -135,13 +139,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(17 rows) +(14 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -165,13 +169,13 @@ QUERY PLAN Order: o."time" Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(17 rows) +(14 rows) -- test startup and runtime exclusion together :PREFIX @@ -195,13 +199,13 @@ QUERY PLAN Order: o."time" DESC Chunks excluded during startup: 0 Chunks excluded during runtime: 2 - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_1 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_2 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o_3 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(17 rows) +(14 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -245,22 +249,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 1) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(19 rows) RESET enable_nestloop; -- test JOIN @@ -282,18 +286,18 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=2 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Result (actual rows=6 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=6 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) -(21 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_1 (actual rows=6 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk o2_3 (never executed) +(16 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -314,11 +318,11 @@ QUERY PLAN Merge Cond: (o1."time" = ((InitPlan 1).col1)) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=13674 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=3598 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (actual rows=5038 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (actual rows=5038 loops=1) Index Cond: (device_id = 1) -> Sort (actual rows=1 loops=1) Sort Key: ((InitPlan 1).col1) @@ -328,10 +332,10 @@ QUERY PLAN -> Limit (actual rows=1 loops=1) -> Custom Scan (ChunkAppend) on metrics (actual rows=1 loops=1) Order: metrics."time" DESC - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) -(27 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_time_idx on _hyper_X_X_chunk (never executed) +(21 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -353,22 +357,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -386,22 +390,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -438,22 +442,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -471,22 +475,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -504,22 +508,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -538,22 +542,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -571,22 +575,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -630,21 +634,21 @@ QUERY PLAN -> Nested Loop (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=1 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=1 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) -(24 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -663,22 +667,22 @@ QUERY PLAN Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(26 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -698,33 +702,33 @@ QUERY PLAN Merge Cond: (o3."time" = o1."time") -> Custom Scan (ChunkAppend) on metrics o3 (actual rows=100 loops=1) Order: o3."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_1 (actual rows=100 loops=1) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_2 (never executed) Index Cond: (device_id = 3) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o3_3 (never executed) Index Cond: (device_id = 3) -> Materialize (actual rows=100 loops=1) -> Merge Join (actual rows=100 loops=1) Merge Cond: (o1."time" = o2."time") -> Custom Scan (ChunkAppend) on metrics o1 (actual rows=100 loops=1) Order: o1."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_1 (actual rows=100 loops=1) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_2 (never executed) Index Cond: (device_id = 1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o1_3 (never executed) Index Cond: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(40 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_space' @@ -758,22 +762,22 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Materialize (actual rows=2 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -(30 rows) +(21 rows) -- test LATERAL with ordered append in the lateral query :PREFIX @@ -798,20 +802,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=2 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=2 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(32 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(23 rows) -- test plan with best index is chosen -- this should use device_id, time index @@ -847,20 +851,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(27 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(18 rows) -- test LATERAL with correlated query -- only last chunk should be executed @@ -884,29 +888,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(39 rows) +(30 rows) -- test LATERAL with correlated query -- only 2nd chunk should be executed @@ -930,29 +934,29 @@ QUERY PLAN Order: o."time" -> Merge Append (actual rows=0 loops=2) Sort Key: o_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (actual rows=1 loops=2) Sort Key: o_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=1 loops=2) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -> Merge Append (never executed) Sort Key: o_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (never executed) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval))) -(39 rows) +(30 rows) -- test startup and runtime exclusion together :PREFIX @@ -976,29 +980,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -> Merge Append (actual rows=1 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=1 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" < now())) -(39 rows) +(30 rows) -- test startup and runtime exclusion together -- all chunks should be filtered @@ -1023,29 +1027,29 @@ QUERY PLAN Order: o."time" DESC -> Merge Append (actual rows=0 loops=3) Sort Key: o_1."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_1 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_2 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_3 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_4."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_4 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_5 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_6 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -> Merge Append (actual rows=0 loops=3) Sort Key: o_7."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_7 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_8 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o_9 (actual rows=0 loops=3) Index Cond: (("time" >= g."time") AND ("time" < (g."time" + '@ 1 day'::interval)) AND ("time" > now())) -(39 rows) +(30 rows) -- test JOIN -- no exclusion on joined table because quals are not propagated yet @@ -1077,13 +1081,13 @@ QUERY PLAN -> Materialize (actual rows=13674 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=13674 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=3598 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (actual rows=5038 loops=1) Index Cond: ((device_id = 2) AND ("time" < 'Tue Feb 01 00:00:00 2000 PST'::timestamp with time zone)) -(25 rows) +(22 rows) RESET enable_nestloop; -- test JOIN @@ -1107,19 +1111,19 @@ QUERY PLAN Order: o1."time" -> Merge Append (actual rows=2 loops=1) Sort Key: o1_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_1 (actual rows=2 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_2 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_3 (actual rows=1 loops=1) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Merge Append (never executed) Sort Key: o1_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_4 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_5 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o1_6 (never executed) Index Cond: ("time" < 'Sat Jan 08 00:00:00 2000 PST'::timestamp with time zone) -> Materialize (actual rows=10 loops=1) -> Result (actual rows=6 loops=1) @@ -1127,20 +1131,20 @@ QUERY PLAN Order: o2."time" -> Merge Append (actual rows=6 loops=1) Sort Key: o2_1."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_1 (actual rows=2 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_2 (actual rows=4 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_3 (actual rows=2 loops=1) -> Merge Append (never executed) Sort Key: o2_4."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_4 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_5 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_6 (never executed) -> Merge Append (never executed) Sort Key: o2_7."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) -(55 rows) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_7 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_8 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk o2_9 (never executed) +(40 rows) -- test join against max query -- not ChunkAppend so no chunk exclusion @@ -1177,20 +1181,20 @@ QUERY PLAN Order: metrics_space."time" DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (actual rows=1 loops=1) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -> Merge Append (never executed) Sort Key: _hyper_X_X_chunk."time" DESC - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) - -> Index Only Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) -(42 rows) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) + -> Index Scan Backward using _hyper_X_X_chunk_metrics_space_time_idx on _hyper_X_X_chunk (never executed) +(33 rows) RESET enable_hashjoin; RESET enable_nestloop; @@ -1221,13 +1225,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with USING -- should use 2 ChunkAppend @@ -1254,13 +1258,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test NATURAL JOIN on time column -- should use 2 ChunkAppend @@ -1306,13 +1310,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test RIGHT JOIN on time column -- should use 2 ChunkAppend @@ -1339,13 +1343,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ON clause expression order switched -- should use 2 ChunkAppend @@ -1372,13 +1376,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with equality condition in WHERE clause -- should use 2 ChunkAppend @@ -1406,13 +1410,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with ORDER BY 2nd hypertable -- should use 2 ChunkAppend @@ -1439,13 +1443,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column and device_id -- should use 2 ChunkAppend @@ -1521,13 +1525,13 @@ QUERY PLAN Filter: (device_id = 1) -> Materialize (actual rows=100 loops=1) -> Append (actual rows=100 loops=1) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: ((device_id = 1) AND (device_id = 1)) -(21 rows) +(18 rows) -- test JOIN on time column with implicit join -- should use 2 ChunkAppend @@ -1555,13 +1559,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(23 rows) +(20 rows) -- test JOIN on time column with 3 hypertables -- should use 3 ChunkAppend @@ -1601,13 +1605,13 @@ QUERY PLAN -> Materialize (actual rows=100 loops=1) -> Custom Scan (ChunkAppend) on metrics_space o2 (actual rows=100 loops=1) Order: o2."time" - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_1 (actual rows=100 loops=1) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_2 (never executed) Index Cond: (device_id = 2) - -> Index Only Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) + -> Index Scan using _hyper_X_X_chunk_metrics_space_device_id_time_idx on _hyper_X_X_chunk o2_3 (never executed) Index Cond: (device_id = 2) -(34 rows) +(31 rows) RESET enable_seqscan; \set TEST_TABLE 'metrics_compressed' diff --git a/tsl/test/shared/sql/ordered_append_join.sql.in b/tsl/test/shared/sql/ordered_append_join.sql.in index 277f49a96ef..762a4d5317b 100644 --- a/tsl/test/shared/sql/ordered_append_join.sql.in +++ b/tsl/test/shared/sql/ordered_append_join.sql.in @@ -4,6 +4,11 @@ SET timescaledb.enable_now_constify TO FALSE; +-- We disable index only scans to avoid some flakiness. It is not +-- needed for the tests and it is only important which index is +-- picked. +SET enable_indexonlyscan TO FALSE; + SELECT format('include/%s.sql', :'TEST_BASE_NAME') as "TEST_QUERY_NAME", format('%s/shared/results/%s_results_uncompressed.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_UNCOMPRESSED",