-- This file and its contents are licensed under the Timescale License.
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set PREFIX 'EXPLAIN (ANALYZE,VERBOSE,SUMMARY OFF,TIMING OFF,BUFFERS OFF, COSTS OFF)'
\i include/modify_exclusion_load.sql
-- This file and its contents are licensed under the Timescale License.
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
CREATE TABLE metrics_int2(c1 int,c2 int, c3 int, c4 int, c5 int, time int2 NOT NULL, value float, data text);
CREATE TABLE metrics_int4(c1 int,c2 int, c3 int, c4 int, c5 int, time int4 NOT NULL, value float, data text);
CREATE TABLE metrics_int8(c1 int,c2 int, c3 int, c4 int, c5 int, time int8 NOT NULL, value float, data text);
CREATE TABLE metrics_date(c1 int,c2 int, c3 int, c4 int, c5 int, time date NOT NULL, value float, data text);
CREATE TABLE metrics_timestamp(c1 int,c2 int, c3 int, c4 int, c5 int, time timestamp NOT NULL, value float, data text);
CREATE TABLE metrics_timestamptz(c1 int,c2 int, c3 int, c4 int, c5 int, time timestamptz NOT NULL, value float, data text);
CREATE TABLE metrics_space(c1 int,c2 int, c3 int, c4 int, c5 int, time timestamp NOT NULL, device text, value float, data text);
SELECT table_name FROM create_hypertable('metrics_int2','time',chunk_time_interval:=10);
  table_name  
--------------
 metrics_int2

SELECT table_name FROM create_hypertable('metrics_int4','time',chunk_time_interval:=10);
  table_name  
--------------
 metrics_int4

SELECT table_name FROM create_hypertable('metrics_int8','time',chunk_time_interval:=10);
  table_name  
--------------
 metrics_int8

SELECT table_name FROM create_hypertable('metrics_date','time');
  table_name  
--------------
 metrics_date

SELECT table_name FROM create_hypertable('metrics_timestamp','time');
psql:include/modify_exclusion_load.sql:17: WARNING:  column type "timestamp without time zone" used for "time" does not follow best practices
    table_name     
-------------------
 metrics_timestamp

SELECT table_name FROM create_hypertable('metrics_timestamptz','time');
     table_name      
---------------------
 metrics_timestamptz

SELECT table_name FROM create_hypertable('metrics_space','time','device',4);
psql:include/modify_exclusion_load.sql:19: WARNING:  column type "timestamp without time zone" used for "time" does not follow best practices
  table_name   
---------------
 metrics_space

CREATE FUNCTION drop_column(text) RETURNS VOID LANGUAGE PLPGSQL AS $$
DECLARE
  tbl name;
BEGIN
  FOR tbl IN SELECT 'metrics_' || unnest(ARRAY['int2','int4','int8','date','timestamp','timestamptz','space'])
  LOOP
    EXECUTE format('ALTER TABLE %I DROP COLUMN %I;', tbl, $1);
  END LOOP;
END;
$$;
-- create 4 chunks each with different physical layout
SELECT drop_column('c1');
 drop_column 
-------------
 

INSERT INTO metrics_int2(time) VALUES (0);
INSERT INTO metrics_int4(time) VALUES (0);
INSERT INTO metrics_int8(time) VALUES (0);
INSERT INTO metrics_date(time) VALUES ('2000-01-01');
INSERT INTO metrics_timestamp(time) VALUES ('2000-01-01');
INSERT INTO metrics_timestamptz(time) VALUES ('2000-01-01');
INSERT INTO metrics_space(time,device) VALUES ('2000-01-01','1'),('2000-01-01','2');
SELECT drop_column('c2');
 drop_column 
-------------
 

INSERT INTO metrics_int2(time) VALUES (10);
INSERT INTO metrics_int4(time) VALUES (10);
INSERT INTO metrics_int8(time) VALUES (10);
INSERT INTO metrics_date(time) VALUES ('2001-01-01');
INSERT INTO metrics_timestamp(time) VALUES ('2001-01-01');
INSERT INTO metrics_timestamptz(time) VALUES ('2001-01-01');
INSERT INTO metrics_space(time,device) VALUES ('2001-01-01','1'),('2001-01-01','2');
SELECT drop_column('c3');
 drop_column 
-------------
 

INSERT INTO metrics_int2(time) VALUES (20);
INSERT INTO metrics_int4(time) VALUES (20);
INSERT INTO metrics_int8(time) VALUES (20);
INSERT INTO metrics_date(time) VALUES ('2002-01-01');
INSERT INTO metrics_timestamp(time) VALUES ('2002-01-01');
INSERT INTO metrics_timestamptz(time) VALUES ('2002-01-01');
INSERT INTO metrics_space(time,device) VALUES ('2002-01-01','1'),('2002-01-01','2');
SELECT drop_column('c4');
 drop_column 
-------------
 

INSERT INTO metrics_int2(time) VALUES (30);
INSERT INTO metrics_int4(time) VALUES (30);
INSERT INTO metrics_int8(time) VALUES (30);
INSERT INTO metrics_date(time) VALUES ('2003-01-01');
INSERT INTO metrics_timestamp(time) VALUES ('2003-01-01');
INSERT INTO metrics_timestamptz(time) VALUES ('2003-01-01');
INSERT INTO metrics_space(time,device) VALUES ('2003-01-01','1'),('2003-01-01','2');
SELECT drop_column('c5');
 drop_column 
-------------
 

CREATE TABLE metrics_compressed(time timestamptz NOT NULL, device int, value float);
SELECT table_name FROM create_hypertable('metrics_compressed','time');
     table_name     
--------------------
 metrics_compressed

ALTER TABLE metrics_compressed SET (timescaledb.compress);
-- create first chunk and compress
INSERT INTO metrics_compressed VALUES ('2000-01-01',1,0.5);
SELECT count(compress_chunk(chunk)) FROM show_chunks('metrics_compressed') chunk;
 count 
-------
     1

-- create more chunks
INSERT INTO metrics_compressed VALUES ('2010-01-01',1,0.5),('2011-01-01',1,0.5),('2012-01-01',1,0.5);
-- immutable constraints
-- should not have ChunkAppend since constraint is immutable and postgres already does the exclusion
-- should only hit 1 chunk and base table
BEGIN;
:PREFIX DELETE FROM metrics_int2 WHERE time = 15;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int2 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_1_9_chunk metrics_int2_1
         ->  Index Scan using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk metrics_int2_1 (actual rows=0.00 loops=1)
               Output: metrics_int2_1.tableoid, metrics_int2_1.ctid
               Index Cond: (metrics_int2_1."time" = 15)

:PREFIX DELETE FROM metrics_int4 WHERE time = 15;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_10_chunk metrics_int4_1
         ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk metrics_int4_1 (actual rows=0.00 loops=1)
               Output: metrics_int4_1.tableoid, metrics_int4_1.ctid
               Index Cond: (metrics_int4_1."time" = 15)

:PREFIX DELETE FROM metrics_int8 WHERE time = 15;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int8 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_3_11_chunk metrics_int8_1
         ->  Index Scan using _hyper_3_11_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_11_chunk metrics_int8_1 (actual rows=0.00 loops=1)
               Output: metrics_int8_1.tableoid, metrics_int8_1.ctid
               Index Cond: (metrics_int8_1."time" = 15)

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int2 SET value = 0.5 WHERE time = 15;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int2 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_1_9_chunk metrics_int2_1
         ->  Result (actual rows=0.00 loops=1)
               Output: '0.5'::double precision, metrics_int2_1.tableoid, metrics_int2_1.ctid
               ->  Index Scan using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk metrics_int2_1 (actual rows=0.00 loops=1)
                     Output: metrics_int2_1.tableoid, metrics_int2_1.ctid
                     Index Cond: (metrics_int2_1."time" = 15)

:PREFIX UPDATE metrics_int4 SET value = 0.5 WHERE time = 15;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4_1
         ->  Result (actual rows=0.00 loops=1)
               Output: '0.5'::double precision, metrics_int4_1.tableoid, metrics_int4_1.ctid
               ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk metrics_int4_1 (actual rows=0.00 loops=1)
                     Output: metrics_int4_1.tableoid, metrics_int4_1.ctid
                     Index Cond: (metrics_int4_1."time" = 15)

:PREFIX UPDATE metrics_int8 SET value = 0.5 WHERE time = 15;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int8 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_3_11_chunk metrics_int8_1
         ->  Result (actual rows=0.00 loops=1)
               Output: '0.5'::double precision, metrics_int8_1.tableoid, metrics_int8_1.ctid
               ->  Index Scan using _hyper_3_11_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_11_chunk metrics_int8_1 (actual rows=0.00 loops=1)
                     Output: metrics_int8_1.tableoid, metrics_int8_1.ctid
                     Index Cond: (metrics_int8_1."time" = 15)

ROLLBACK;
-- stable constraints
-- should have ChunkAppend since constraint is stable
-- should only hit 1 chunk and base table
BEGIN;
:PREFIX DELETE FROM metrics_int2 WHERE time = length(substring(version(),1,23));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int2 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_1_1_chunk metrics_int2
         Delete on _timescaledb_internal._hyper_1_9_chunk metrics_int2
         Delete on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1
         Delete on _timescaledb_internal._hyper_1_25_chunk metrics_int2
         ->  Custom Scan (ChunkAppend) on public.metrics_int2 (actual rows=0.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1 (actual rows=0.00 loops=1)
                     Output: metrics_int2_1.tableoid, metrics_int2_1.ctid
                     Index Cond: (metrics_int2_1."time" = length("substring"(version(), 1, 23)))

:PREFIX DELETE FROM metrics_int4 WHERE time = length(substring(version(),1,23));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk metrics_int4
         Delete on _timescaledb_internal._hyper_2_10_chunk metrics_int4
         Delete on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1
         Delete on _timescaledb_internal._hyper_2_26_chunk metrics_int4
         ->  Custom Scan (ChunkAppend) on public.metrics_int4 (actual rows=0.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1 (actual rows=0.00 loops=1)
                     Output: metrics_int4_1.tableoid, metrics_int4_1.ctid
                     Index Cond: (metrics_int4_1."time" = length("substring"(version(), 1, 23)))

:PREFIX DELETE FROM metrics_int8 WHERE time = length(substring(version(),1,23));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int8 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_3_3_chunk metrics_int8
         Delete on _timescaledb_internal._hyper_3_11_chunk metrics_int8
         Delete on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1
         Delete on _timescaledb_internal._hyper_3_27_chunk metrics_int8
         ->  Custom Scan (ChunkAppend) on public.metrics_int8 (actual rows=0.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_3_19_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1 (actual rows=0.00 loops=1)
                     Output: metrics_int8_1.tableoid, metrics_int8_1.ctid
                     Index Cond: (metrics_int8_1."time" = length("substring"(version(), 1, 23)))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int2 SET value = 0.3 WHERE time = length(substring(version(),1,23));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int2 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_1_1_chunk metrics_int2
         Update on _timescaledb_internal._hyper_1_9_chunk metrics_int2
         Update on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1
         Update on _timescaledb_internal._hyper_1_25_chunk metrics_int2
         ->  Result (actual rows=0.00 loops=1)
               Output: '0.3'::double precision, metrics_int2.tableoid, metrics_int2.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int2 (actual rows=0.00 loops=1)
                     Output: metrics_int2.tableoid, metrics_int2.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1 (actual rows=0.00 loops=1)
                           Output: metrics_int2_1.tableoid, metrics_int2_1.ctid
                           Index Cond: (metrics_int2_1."time" = length("substring"(version(), 1, 23)))

:PREFIX UPDATE metrics_int4 SET value = 0.3 WHERE time = length(substring(version(),1,23));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk metrics_int4
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4
         Update on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1
         Update on _timescaledb_internal._hyper_2_26_chunk metrics_int4
         ->  Result (actual rows=0.00 loops=1)
               Output: '0.3'::double precision, metrics_int4.tableoid, metrics_int4.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int4 (actual rows=0.00 loops=1)
                     Output: metrics_int4.tableoid, metrics_int4.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1 (actual rows=0.00 loops=1)
                           Output: metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" = length("substring"(version(), 1, 23)))

:PREFIX UPDATE metrics_int8 SET value = 0.3 WHERE time = length(substring(version(),1,23));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int8 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_3_3_chunk metrics_int8
         Update on _timescaledb_internal._hyper_3_11_chunk metrics_int8
         Update on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1
         Update on _timescaledb_internal._hyper_3_27_chunk metrics_int8
         ->  Result (actual rows=0.00 loops=1)
               Output: '0.3'::double precision, metrics_int8.tableoid, metrics_int8.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int8 (actual rows=0.00 loops=1)
                     Output: metrics_int8.tableoid, metrics_int8.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_3_19_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1 (actual rows=0.00 loops=1)
                           Output: metrics_int8_1.tableoid, metrics_int8_1.ctid
                           Index Cond: (metrics_int8_1."time" = length("substring"(version(), 1, 23)))

ROLLBACK;
-- should have ChunkAppend since constraint is stable
-- should only hit 1 chunk and base table, toplevel rows should be 1
BEGIN;
:PREFIX DELETE FROM metrics_int2 WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Delete on public.metrics_int2 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Delete on _timescaledb_internal._hyper_1_1_chunk metrics_int2
         Delete on _timescaledb_internal._hyper_1_9_chunk metrics_int2
         Delete on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1
         Delete on _timescaledb_internal._hyper_1_25_chunk metrics_int2
         ->  Custom Scan (ChunkAppend) on public.metrics_int2 (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                     Output: metrics_int2_1.tableoid, metrics_int2_1.ctid
                     Index Cond: (metrics_int2_1."time" = length("substring"(version(), 1, 20)))

:PREFIX DELETE FROM metrics_int4 WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Delete on public.metrics_int4 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Delete on _timescaledb_internal._hyper_2_2_chunk metrics_int4
         Delete on _timescaledb_internal._hyper_2_10_chunk metrics_int4
         Delete on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1
         Delete on _timescaledb_internal._hyper_2_26_chunk metrics_int4
         ->  Custom Scan (ChunkAppend) on public.metrics_int4 (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                     Output: metrics_int4_1.tableoid, metrics_int4_1.ctid
                     Index Cond: (metrics_int4_1."time" = length("substring"(version(), 1, 20)))

:PREFIX DELETE FROM metrics_int8 WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Delete on public.metrics_int8 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Delete on _timescaledb_internal._hyper_3_3_chunk metrics_int8
         Delete on _timescaledb_internal._hyper_3_11_chunk metrics_int8
         Delete on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1
         Delete on _timescaledb_internal._hyper_3_27_chunk metrics_int8
         ->  Custom Scan (ChunkAppend) on public.metrics_int8 (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_3_19_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1 (actual rows=1.00 loops=1)
                     Output: metrics_int8_1.tableoid, metrics_int8_1.ctid
                     Index Cond: (metrics_int8_1."time" = length("substring"(version(), 1, 20)))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int2 SET value = 0.4 WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Update on public.metrics_int2 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Update on _timescaledb_internal._hyper_1_1_chunk metrics_int2
         Update on _timescaledb_internal._hyper_1_9_chunk metrics_int2
         Update on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1
         Update on _timescaledb_internal._hyper_1_25_chunk metrics_int2
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.4'::double precision, metrics_int2.tableoid, metrics_int2.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int2 (actual rows=1.00 loops=1)
                     Output: metrics_int2.tableoid, metrics_int2.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                           Output: metrics_int2_1.tableoid, metrics_int2_1.ctid
                           Index Cond: (metrics_int2_1."time" = length("substring"(version(), 1, 20)))

:PREFIX UPDATE metrics_int4 SET value = 0.4 WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Update on public.metrics_int4 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Update on _timescaledb_internal._hyper_2_2_chunk metrics_int4
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4
         Update on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1
         Update on _timescaledb_internal._hyper_2_26_chunk metrics_int4
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.4'::double precision, metrics_int4.tableoid, metrics_int4.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int4 (actual rows=1.00 loops=1)
                     Output: metrics_int4.tableoid, metrics_int4.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" = length("substring"(version(), 1, 20)))

:PREFIX UPDATE metrics_int8 SET value = 0.4 WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Update on public.metrics_int8 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Update on _timescaledb_internal._hyper_3_3_chunk metrics_int8
         Update on _timescaledb_internal._hyper_3_11_chunk metrics_int8
         Update on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1
         Update on _timescaledb_internal._hyper_3_27_chunk metrics_int8
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.4'::double precision, metrics_int8.tableoid, metrics_int8.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int8 (actual rows=1.00 loops=1)
                     Output: metrics_int8.tableoid, metrics_int8.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_3_19_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1 (actual rows=1.00 loops=1)
                           Output: metrics_int8_1.tableoid, metrics_int8_1.ctid
                           Index Cond: (metrics_int8_1."time" = length("substring"(version(), 1, 20)))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int2 SET value = 0.1 * value, data = 'update' WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Update on public.metrics_int2 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Update on _timescaledb_internal._hyper_1_1_chunk metrics_int2
         Update on _timescaledb_internal._hyper_1_9_chunk metrics_int2
         Update on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1
         Update on _timescaledb_internal._hyper_1_25_chunk metrics_int2
         ->  Result (actual rows=1.00 loops=1)
               Output: ('0.1'::double precision * metrics_int2.value), 'update'::text, metrics_int2.tableoid, metrics_int2.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int2 (actual rows=1.00 loops=1)
                     Output: metrics_int2.value, metrics_int2.tableoid, metrics_int2.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                           Output: metrics_int2_1.value, metrics_int2_1.tableoid, metrics_int2_1.ctid
                           Index Cond: (metrics_int2_1."time" = length("substring"(version(), 1, 20)))

:PREFIX UPDATE metrics_int4 SET value = 0.1 * value, data = 'update' WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Update on public.metrics_int4 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Update on _timescaledb_internal._hyper_2_2_chunk metrics_int4
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4
         Update on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1
         Update on _timescaledb_internal._hyper_2_26_chunk metrics_int4
         ->  Result (actual rows=1.00 loops=1)
               Output: ('0.1'::double precision * metrics_int4.value), 'update'::text, metrics_int4.tableoid, metrics_int4.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int4 (actual rows=1.00 loops=1)
                     Output: metrics_int4.value, metrics_int4.tableoid, metrics_int4.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1.value, metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" = length("substring"(version(), 1, 20)))

:PREFIX UPDATE metrics_int8 SET value = 0.1 * value, data = 'update' WHERE time = length(substring(version(),1,20)) RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), "time"
   ->  Update on public.metrics_int8 (actual rows=1.00 loops=1)
         Output: 'returning'::text, "time"
         Update on _timescaledb_internal._hyper_3_3_chunk metrics_int8
         Update on _timescaledb_internal._hyper_3_11_chunk metrics_int8
         Update on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1
         Update on _timescaledb_internal._hyper_3_27_chunk metrics_int8
         ->  Result (actual rows=1.00 loops=1)
               Output: ('0.1'::double precision * metrics_int8.value), 'update'::text, metrics_int8.tableoid, metrics_int8.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int8 (actual rows=1.00 loops=1)
                     Output: metrics_int8.value, metrics_int8.tableoid, metrics_int8.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_3_19_chunk_metrics_int8_time_idx on _timescaledb_internal._hyper_3_19_chunk metrics_int8_1 (actual rows=1.00 loops=1)
                           Output: metrics_int8_1.value, metrics_int8_1.tableoid, metrics_int8_1.ctid
                           Index Cond: (metrics_int8_1."time" = length("substring"(version(), 1, 20)))

ROLLBACK;
-- immutable constraints
-- should not have ChunkAppend since constraint is immutable and postgres already does the exclusion
-- should only hit 1 chunk and base table
BEGIN;
:PREFIX DELETE FROM metrics_date WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_date (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_4_4_chunk metrics_date_1
         ->  Index Scan using _hyper_4_4_chunk_metrics_date_time_idx on _timescaledb_internal._hyper_4_4_chunk metrics_date_1 (actual rows=1.00 loops=1)
               Output: metrics_date_1.tableoid, metrics_date_1.ctid
               Index Cond: (metrics_date_1."time" = '01-01-2000'::date)

:PREFIX DELETE FROM metrics_timestamp WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_timestamp (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1
         ->  Index Scan using _hyper_5_5_chunk_metrics_timestamp_time_idx on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1 (actual rows=1.00 loops=1)
               Output: metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
               Index Cond: (metrics_timestamp_1."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone)

:PREFIX DELETE FROM metrics_timestamptz WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_timestamptz (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1
         ->  Index Scan using _hyper_6_6_chunk_metrics_timestamptz_time_idx on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1 (actual rows=1.00 loops=1)
               Output: metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
               Index Cond: (metrics_timestamptz_1."time" = 'Sat Jan 01 00:00:00 2000 PST'::timestamp with time zone)

:PREFIX DELETE FROM metrics_space WHERE time = '2000-01-01' AND device = '1';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_space (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         ->  Index Scan using _hyper_7_7_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
               Output: metrics_space_1.tableoid, metrics_space_1.ctid
               Index Cond: ((metrics_space_1.device = '1'::text) AND (metrics_space_1."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone))

:PREFIX DELETE FROM metrics_space WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_space (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         Delete on _timescaledb_internal._hyper_7_8_chunk metrics_space_2
         ->  Append (actual rows=1.00 loops=1)
               ->  Index Scan using _hyper_7_7_chunk_metrics_space_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=0.00 loops=1)
                     Output: metrics_space_1.tableoid, metrics_space_1.ctid
                     Index Cond: (metrics_space_1."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone)
               ->  Index Scan using _hyper_7_8_chunk_metrics_space_time_idx on _timescaledb_internal._hyper_7_8_chunk metrics_space_2 (actual rows=1.00 loops=1)
                     Output: metrics_space_2.tableoid, metrics_space_2.ctid
                     Index Cond: (metrics_space_2."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone)

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_date SET value = 0.6 WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_date (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_4_4_chunk metrics_date_1
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.6'::double precision, metrics_date_1.tableoid, metrics_date_1.ctid
               ->  Index Scan using _hyper_4_4_chunk_metrics_date_time_idx on _timescaledb_internal._hyper_4_4_chunk metrics_date_1 (actual rows=1.00 loops=1)
                     Output: metrics_date_1.tableoid, metrics_date_1.ctid
                     Index Cond: (metrics_date_1."time" = '01-01-2000'::date)

:PREFIX UPDATE metrics_timestamp SET value = 0.6 WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_timestamp (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.6'::double precision, metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
               ->  Index Scan using _hyper_5_5_chunk_metrics_timestamp_time_idx on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1 (actual rows=1.00 loops=1)
                     Output: metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
                     Index Cond: (metrics_timestamp_1."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone)

:PREFIX UPDATE metrics_timestamptz SET value = 0.6 WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_timestamptz (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.6'::double precision, metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
               ->  Index Scan using _hyper_6_6_chunk_metrics_timestamptz_time_idx on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1 (actual rows=1.00 loops=1)
                     Output: metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
                     Index Cond: (metrics_timestamptz_1."time" = 'Sat Jan 01 00:00:00 2000 PST'::timestamp with time zone)

:PREFIX UPDATE metrics_space SET value = 0.6 WHERE time = '2000-01-01' AND device = '1';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_space (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.6'::double precision, metrics_space_1.tableoid, metrics_space_1.ctid
               ->  Index Scan using _hyper_7_7_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
                     Output: metrics_space_1.tableoid, metrics_space_1.ctid
                     Index Cond: ((metrics_space_1.device = '1'::text) AND (metrics_space_1."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone))

:PREFIX UPDATE metrics_space SET value = 0.6 WHERE time = '2000-01-01';
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_space (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         Update on _timescaledb_internal._hyper_7_8_chunk metrics_space_2
         ->  Result (actual rows=2.00 loops=1)
               Output: '0.6'::double precision, metrics_space.tableoid, metrics_space.ctid
               ->  Append (actual rows=2.00 loops=1)
                     ->  Index Scan using _hyper_7_7_chunk_metrics_space_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
                           Output: metrics_space_1.tableoid, metrics_space_1.ctid
                           Index Cond: (metrics_space_1."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone)
                     ->  Index Scan using _hyper_7_8_chunk_metrics_space_time_idx on _timescaledb_internal._hyper_7_8_chunk metrics_space_2 (actual rows=1.00 loops=1)
                           Output: metrics_space_2.tableoid, metrics_space_2.ctid
                           Index Cond: (metrics_space_2."time" = 'Sat Jan 01 00:00:00 2000'::timestamp without time zone)

ROLLBACK;
-- stable constraints
-- should have ChunkAppend since constraint is stable
-- should only hit 1 chunk and base table
BEGIN;
:PREFIX DELETE FROM metrics_date WHERE time = '2000-01-01'::text::date;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_date (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_4_4_chunk metrics_date_1
         Delete on _timescaledb_internal._hyper_4_12_chunk metrics_date
         Delete on _timescaledb_internal._hyper_4_20_chunk metrics_date
         Delete on _timescaledb_internal._hyper_4_28_chunk metrics_date
         ->  Custom Scan (ChunkAppend) on public.metrics_date (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_4_4_chunk_metrics_date_time_idx on _timescaledb_internal._hyper_4_4_chunk metrics_date_1 (actual rows=1.00 loops=1)
                     Output: metrics_date_1.tableoid, metrics_date_1.ctid
                     Index Cond: (metrics_date_1."time" = ('2000-01-01'::cstring)::date)

:PREFIX DELETE FROM metrics_timestamp WHERE time = '2000-01-01'::text::timestamp;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_timestamp (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1
         Delete on _timescaledb_internal._hyper_5_13_chunk metrics_timestamp
         Delete on _timescaledb_internal._hyper_5_21_chunk metrics_timestamp
         Delete on _timescaledb_internal._hyper_5_29_chunk metrics_timestamp
         ->  Custom Scan (ChunkAppend) on public.metrics_timestamp (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_5_5_chunk_metrics_timestamp_time_idx on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1 (actual rows=1.00 loops=1)
                     Output: metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
                     Index Cond: (metrics_timestamp_1."time" = ('2000-01-01'::cstring)::timestamp without time zone)

:PREFIX DELETE FROM metrics_timestamptz WHERE time = '2000-01-01'::text::timestamptz;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_timestamptz (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1
         Delete on _timescaledb_internal._hyper_6_14_chunk metrics_timestamptz
         Delete on _timescaledb_internal._hyper_6_22_chunk metrics_timestamptz
         Delete on _timescaledb_internal._hyper_6_30_chunk metrics_timestamptz
         ->  Custom Scan (ChunkAppend) on public.metrics_timestamptz (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_6_6_chunk_metrics_timestamptz_time_idx on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1 (actual rows=1.00 loops=1)
                     Output: metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
                     Index Cond: (metrics_timestamptz_1."time" = ('2000-01-01'::cstring)::timestamp with time zone)

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_date SET value = 0.9 WHERE time = '2000-01-01'::text::date;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_date (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_4_4_chunk metrics_date_1
         Update on _timescaledb_internal._hyper_4_12_chunk metrics_date
         Update on _timescaledb_internal._hyper_4_20_chunk metrics_date
         Update on _timescaledb_internal._hyper_4_28_chunk metrics_date
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.9'::double precision, metrics_date.tableoid, metrics_date.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_date (actual rows=1.00 loops=1)
                     Output: metrics_date.tableoid, metrics_date.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_4_4_chunk_metrics_date_time_idx on _timescaledb_internal._hyper_4_4_chunk metrics_date_1 (actual rows=1.00 loops=1)
                           Output: metrics_date_1.tableoid, metrics_date_1.ctid
                           Index Cond: (metrics_date_1."time" = ('2000-01-01'::cstring)::date)

:PREFIX UPDATE metrics_timestamp SET value = 0.9 WHERE time = '2000-01-01'::text::timestamp;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_timestamp (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1
         Update on _timescaledb_internal._hyper_5_13_chunk metrics_timestamp
         Update on _timescaledb_internal._hyper_5_21_chunk metrics_timestamp
         Update on _timescaledb_internal._hyper_5_29_chunk metrics_timestamp
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.9'::double precision, metrics_timestamp.tableoid, metrics_timestamp.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_timestamp (actual rows=1.00 loops=1)
                     Output: metrics_timestamp.tableoid, metrics_timestamp.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_5_5_chunk_metrics_timestamp_time_idx on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1 (actual rows=1.00 loops=1)
                           Output: metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
                           Index Cond: (metrics_timestamp_1."time" = ('2000-01-01'::cstring)::timestamp without time zone)

:PREFIX UPDATE metrics_timestamptz SET value = 0.9 WHERE time = '2000-01-01'::text::timestamptz;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_timestamptz (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1
         Update on _timescaledb_internal._hyper_6_14_chunk metrics_timestamptz
         Update on _timescaledb_internal._hyper_6_22_chunk metrics_timestamptz
         Update on _timescaledb_internal._hyper_6_30_chunk metrics_timestamptz
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.9'::double precision, metrics_timestamptz.tableoid, metrics_timestamptz.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_timestamptz (actual rows=1.00 loops=1)
                     Output: metrics_timestamptz.tableoid, metrics_timestamptz.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_6_6_chunk_metrics_timestamptz_time_idx on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1 (actual rows=1.00 loops=1)
                           Output: metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
                           Index Cond: (metrics_timestamptz_1."time" = ('2000-01-01'::cstring)::timestamp with time zone)

ROLLBACK;
-- space partitioning
-- should have ChunkAppend since constraint is stable
-- should only hit 1 chunk and base table
BEGIN;
:PREFIX DELETE FROM metrics_space WHERE time = '2000-01-01'::text::timestamptz AND device = format('1');
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_space (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         Delete on _timescaledb_internal._hyper_7_8_chunk metrics_space_2
         Delete on _timescaledb_internal._hyper_7_15_chunk metrics_space
         Delete on _timescaledb_internal._hyper_7_16_chunk metrics_space
         Delete on _timescaledb_internal._hyper_7_23_chunk metrics_space
         Delete on _timescaledb_internal._hyper_7_24_chunk metrics_space
         Delete on _timescaledb_internal._hyper_7_31_chunk metrics_space
         Delete on _timescaledb_internal._hyper_7_32_chunk metrics_space
         ->  Custom Scan (ChunkAppend) on public.metrics_space (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 6
               ->  Index Scan using _hyper_7_7_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
                     Output: metrics_space_1.tableoid, metrics_space_1.ctid
                     Index Cond: ((metrics_space_1.device = format('1'::text)) AND (metrics_space_1."time" = ('2000-01-01'::cstring)::timestamp with time zone))
               ->  Index Scan using _hyper_7_8_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_8_chunk metrics_space_2 (actual rows=0.00 loops=1)
                     Output: metrics_space_2.tableoid, metrics_space_2.ctid
                     Index Cond: ((metrics_space_2.device = format('1'::text)) AND (metrics_space_2."time" = ('2000-01-01'::cstring)::timestamp with time zone))

ROLLBACK;
BEGIN;
:PREFIX DELETE FROM metrics_space WHERE device = format('1');
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_space (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         Delete on _timescaledb_internal._hyper_7_8_chunk metrics_space_2
         Delete on _timescaledb_internal._hyper_7_15_chunk metrics_space_3
         Delete on _timescaledb_internal._hyper_7_16_chunk metrics_space_4
         Delete on _timescaledb_internal._hyper_7_23_chunk metrics_space_5
         Delete on _timescaledb_internal._hyper_7_24_chunk metrics_space_6
         Delete on _timescaledb_internal._hyper_7_31_chunk metrics_space_7
         Delete on _timescaledb_internal._hyper_7_32_chunk metrics_space_8
         ->  Custom Scan (ChunkAppend) on public.metrics_space (actual rows=4.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 0
               ->  Index Scan using _hyper_7_7_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
                     Output: metrics_space_1.tableoid, metrics_space_1.ctid
                     Index Cond: (metrics_space_1.device = format('1'::text))
               ->  Index Scan using _hyper_7_8_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_8_chunk metrics_space_2 (actual rows=0.00 loops=1)
                     Output: metrics_space_2.tableoid, metrics_space_2.ctid
                     Index Cond: (metrics_space_2.device = format('1'::text))
               ->  Index Scan using _hyper_7_15_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_15_chunk metrics_space_3 (actual rows=1.00 loops=1)
                     Output: metrics_space_3.tableoid, metrics_space_3.ctid
                     Index Cond: (metrics_space_3.device = format('1'::text))
               ->  Index Scan using _hyper_7_16_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_16_chunk metrics_space_4 (actual rows=0.00 loops=1)
                     Output: metrics_space_4.tableoid, metrics_space_4.ctid
                     Index Cond: (metrics_space_4.device = format('1'::text))
               ->  Index Scan using _hyper_7_23_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_23_chunk metrics_space_5 (actual rows=1.00 loops=1)
                     Output: metrics_space_5.tableoid, metrics_space_5.ctid
                     Index Cond: (metrics_space_5.device = format('1'::text))
               ->  Index Scan using _hyper_7_24_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_24_chunk metrics_space_6 (actual rows=0.00 loops=1)
                     Output: metrics_space_6.tableoid, metrics_space_6.ctid
                     Index Cond: (metrics_space_6.device = format('1'::text))
               ->  Index Scan using _hyper_7_31_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_31_chunk metrics_space_7 (actual rows=1.00 loops=1)
                     Output: metrics_space_7.tableoid, metrics_space_7.ctid
                     Index Cond: (metrics_space_7.device = format('1'::text))
               ->  Index Scan using _hyper_7_32_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_32_chunk metrics_space_8 (actual rows=0.00 loops=1)
                     Output: metrics_space_8.tableoid, metrics_space_8.ctid
                     Index Cond: (metrics_space_8.device = format('1'::text))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_space SET value = 0.1 WHERE time = '2000-01-01'::text::timestamptz AND device = format('1');
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_space (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         Update on _timescaledb_internal._hyper_7_8_chunk metrics_space_2
         Update on _timescaledb_internal._hyper_7_15_chunk metrics_space
         Update on _timescaledb_internal._hyper_7_16_chunk metrics_space
         Update on _timescaledb_internal._hyper_7_23_chunk metrics_space
         Update on _timescaledb_internal._hyper_7_24_chunk metrics_space
         Update on _timescaledb_internal._hyper_7_31_chunk metrics_space
         Update on _timescaledb_internal._hyper_7_32_chunk metrics_space
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.1'::double precision, metrics_space.tableoid, metrics_space.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_space (actual rows=1.00 loops=1)
                     Output: metrics_space.tableoid, metrics_space.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 6
                     ->  Index Scan using _hyper_7_7_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
                           Output: metrics_space_1.tableoid, metrics_space_1.ctid
                           Index Cond: ((metrics_space_1.device = format('1'::text)) AND (metrics_space_1."time" = ('2000-01-01'::cstring)::timestamp with time zone))
                     ->  Index Scan using _hyper_7_8_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_8_chunk metrics_space_2 (actual rows=0.00 loops=1)
                           Output: metrics_space_2.tableoid, metrics_space_2.ctid
                           Index Cond: ((metrics_space_2.device = format('1'::text)) AND (metrics_space_2."time" = ('2000-01-01'::cstring)::timestamp with time zone))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_space SET value = 0.1 WHERE device = format('1');
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_space (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_7_7_chunk metrics_space_1
         Update on _timescaledb_internal._hyper_7_8_chunk metrics_space_2
         Update on _timescaledb_internal._hyper_7_15_chunk metrics_space_3
         Update on _timescaledb_internal._hyper_7_16_chunk metrics_space_4
         Update on _timescaledb_internal._hyper_7_23_chunk metrics_space_5
         Update on _timescaledb_internal._hyper_7_24_chunk metrics_space_6
         Update on _timescaledb_internal._hyper_7_31_chunk metrics_space_7
         Update on _timescaledb_internal._hyper_7_32_chunk metrics_space_8
         ->  Result (actual rows=4.00 loops=1)
               Output: '0.1'::double precision, metrics_space.tableoid, metrics_space.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_space (actual rows=4.00 loops=1)
                     Output: metrics_space.tableoid, metrics_space.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 0
                     ->  Index Scan using _hyper_7_7_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_7_chunk metrics_space_1 (actual rows=1.00 loops=1)
                           Output: metrics_space_1.tableoid, metrics_space_1.ctid
                           Index Cond: (metrics_space_1.device = format('1'::text))
                     ->  Index Scan using _hyper_7_8_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_8_chunk metrics_space_2 (actual rows=0.00 loops=1)
                           Output: metrics_space_2.tableoid, metrics_space_2.ctid
                           Index Cond: (metrics_space_2.device = format('1'::text))
                     ->  Index Scan using _hyper_7_15_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_15_chunk metrics_space_3 (actual rows=1.00 loops=1)
                           Output: metrics_space_3.tableoid, metrics_space_3.ctid
                           Index Cond: (metrics_space_3.device = format('1'::text))
                     ->  Index Scan using _hyper_7_16_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_16_chunk metrics_space_4 (actual rows=0.00 loops=1)
                           Output: metrics_space_4.tableoid, metrics_space_4.ctid
                           Index Cond: (metrics_space_4.device = format('1'::text))
                     ->  Index Scan using _hyper_7_23_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_23_chunk metrics_space_5 (actual rows=1.00 loops=1)
                           Output: metrics_space_5.tableoid, metrics_space_5.ctid
                           Index Cond: (metrics_space_5.device = format('1'::text))
                     ->  Index Scan using _hyper_7_24_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_24_chunk metrics_space_6 (actual rows=0.00 loops=1)
                           Output: metrics_space_6.tableoid, metrics_space_6.ctid
                           Index Cond: (metrics_space_6.device = format('1'::text))
                     ->  Index Scan using _hyper_7_31_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_31_chunk metrics_space_7 (actual rows=1.00 loops=1)
                           Output: metrics_space_7.tableoid, metrics_space_7.ctid
                           Index Cond: (metrics_space_7.device = format('1'::text))
                     ->  Index Scan using _hyper_7_32_chunk_metrics_space_device_time_idx on _timescaledb_internal._hyper_7_32_chunk metrics_space_8 (actual rows=0.00 loops=1)
                           Output: metrics_space_8.tableoid, metrics_space_8.ctid
                           Index Cond: (metrics_space_8.device = format('1'::text))

ROLLBACK;
-- should have ChunkAppend since constraint is stable
-- should only hit 1 chunk and base table, toplevel rows should be 1
BEGIN;
:PREFIX DELETE FROM metrics_date WHERE time = '2000-01-01'::text::date RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), metrics_date_1."time"
   ->  Delete on public.metrics_date (actual rows=1.00 loops=1)
         Output: 'returning'::text, metrics_date_1."time"
         Delete on _timescaledb_internal._hyper_4_4_chunk metrics_date_1
         Delete on _timescaledb_internal._hyper_4_12_chunk metrics_date
         Delete on _timescaledb_internal._hyper_4_20_chunk metrics_date
         Delete on _timescaledb_internal._hyper_4_28_chunk metrics_date
         ->  Custom Scan (ChunkAppend) on public.metrics_date (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_4_4_chunk_metrics_date_time_idx on _timescaledb_internal._hyper_4_4_chunk metrics_date_1 (actual rows=1.00 loops=1)
                     Output: metrics_date_1.tableoid, metrics_date_1.ctid
                     Index Cond: (metrics_date_1."time" = ('2000-01-01'::cstring)::date)

:PREFIX DELETE FROM metrics_timestamp WHERE time = '2000-01-01'::text::timestamp RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), metrics_timestamp_1."time"
   ->  Delete on public.metrics_timestamp (actual rows=1.00 loops=1)
         Output: 'returning'::text, metrics_timestamp_1."time"
         Delete on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1
         Delete on _timescaledb_internal._hyper_5_13_chunk metrics_timestamp
         Delete on _timescaledb_internal._hyper_5_21_chunk metrics_timestamp
         Delete on _timescaledb_internal._hyper_5_29_chunk metrics_timestamp
         ->  Custom Scan (ChunkAppend) on public.metrics_timestamp (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_5_5_chunk_metrics_timestamp_time_idx on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1 (actual rows=1.00 loops=1)
                     Output: metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
                     Index Cond: (metrics_timestamp_1."time" = ('2000-01-01'::cstring)::timestamp without time zone)

:PREFIX DELETE FROM metrics_timestamptz WHERE time = '2000-01-01'::text::timestamptz RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), metrics_timestamptz_1."time"
   ->  Delete on public.metrics_timestamptz (actual rows=1.00 loops=1)
         Output: 'returning'::text, metrics_timestamptz_1."time"
         Delete on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1
         Delete on _timescaledb_internal._hyper_6_14_chunk metrics_timestamptz
         Delete on _timescaledb_internal._hyper_6_22_chunk metrics_timestamptz
         Delete on _timescaledb_internal._hyper_6_30_chunk metrics_timestamptz
         ->  Custom Scan (ChunkAppend) on public.metrics_timestamptz (actual rows=1.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 3
               ->  Index Scan using _hyper_6_6_chunk_metrics_timestamptz_time_idx on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1 (actual rows=1.00 loops=1)
                     Output: metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
                     Index Cond: (metrics_timestamptz_1."time" = ('2000-01-01'::cstring)::timestamp with time zone)

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_date SET value = 0.2 WHERE time = '2000-01-01'::text::date RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), metrics_date_1."time"
   ->  Update on public.metrics_date (actual rows=1.00 loops=1)
         Output: 'returning'::text, metrics_date_1."time"
         Update on _timescaledb_internal._hyper_4_4_chunk metrics_date_1
         Update on _timescaledb_internal._hyper_4_12_chunk metrics_date
         Update on _timescaledb_internal._hyper_4_20_chunk metrics_date
         Update on _timescaledb_internal._hyper_4_28_chunk metrics_date
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.2'::double precision, metrics_date.tableoid, metrics_date.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_date (actual rows=1.00 loops=1)
                     Output: metrics_date.tableoid, metrics_date.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_4_4_chunk_metrics_date_time_idx on _timescaledb_internal._hyper_4_4_chunk metrics_date_1 (actual rows=1.00 loops=1)
                           Output: metrics_date_1.tableoid, metrics_date_1.ctid
                           Index Cond: (metrics_date_1."time" = ('2000-01-01'::cstring)::date)

:PREFIX UPDATE metrics_timestamp SET value = 0.2 WHERE time = '2000-01-01'::text::timestamp RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), metrics_timestamp_1."time"
   ->  Update on public.metrics_timestamp (actual rows=1.00 loops=1)
         Output: 'returning'::text, metrics_timestamp_1."time"
         Update on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1
         Update on _timescaledb_internal._hyper_5_13_chunk metrics_timestamp
         Update on _timescaledb_internal._hyper_5_21_chunk metrics_timestamp
         Update on _timescaledb_internal._hyper_5_29_chunk metrics_timestamp
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.2'::double precision, metrics_timestamp.tableoid, metrics_timestamp.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_timestamp (actual rows=1.00 loops=1)
                     Output: metrics_timestamp.tableoid, metrics_timestamp.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_5_5_chunk_metrics_timestamp_time_idx on _timescaledb_internal._hyper_5_5_chunk metrics_timestamp_1 (actual rows=1.00 loops=1)
                           Output: metrics_timestamp_1.tableoid, metrics_timestamp_1.ctid
                           Index Cond: (metrics_timestamp_1."time" = ('2000-01-01'::cstring)::timestamp without time zone)

:PREFIX UPDATE metrics_timestamptz SET value = 0.2 WHERE time = '2000-01-01'::text::timestamptz RETURNING 'returning', time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=1.00 loops=1)
   Output: ('returning'::text), metrics_timestamptz_1."time"
   ->  Update on public.metrics_timestamptz (actual rows=1.00 loops=1)
         Output: 'returning'::text, metrics_timestamptz_1."time"
         Update on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1
         Update on _timescaledb_internal._hyper_6_14_chunk metrics_timestamptz
         Update on _timescaledb_internal._hyper_6_22_chunk metrics_timestamptz
         Update on _timescaledb_internal._hyper_6_30_chunk metrics_timestamptz
         ->  Result (actual rows=1.00 loops=1)
               Output: '0.2'::double precision, metrics_timestamptz.tableoid, metrics_timestamptz.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_timestamptz (actual rows=1.00 loops=1)
                     Output: metrics_timestamptz.tableoid, metrics_timestamptz.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 3
                     ->  Index Scan using _hyper_6_6_chunk_metrics_timestamptz_time_idx on _timescaledb_internal._hyper_6_6_chunk metrics_timestamptz_1 (actual rows=1.00 loops=1)
                           Output: metrics_timestamptz_1.tableoid, metrics_timestamptz_1.ctid
                           Index Cond: (metrics_timestamptz_1."time" = ('2000-01-01'::cstring)::timestamp with time zone)

ROLLBACK;
-- subselects
-- no chunk exclusion for subqueries joins atm
BEGIN;
:PREFIX DELETE FROM metrics_int4 WHERE time IN (SELECT time FROM metrics_int2) AND time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1
         Delete on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2
         Delete on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3
         Delete on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4
         ->  Hash Join (actual rows=4.00 loops=1)
               Output: metrics_int2.ctid, metrics_int4.tableoid, metrics_int4.ctid, metrics_int2.tableoid
               Inner Unique: true
               Hash Cond: (metrics_int4."time" = metrics_int2."time")
               ->  Append (actual rows=4.00 loops=1)
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1."time", metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2 (actual rows=1.00 loops=1)
                           Output: metrics_int4_2."time", metrics_int4_2.tableoid, metrics_int4_2.ctid
                           Index Cond: (metrics_int4_2."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3 (actual rows=1.00 loops=1)
                           Output: metrics_int4_3."time", metrics_int4_3.tableoid, metrics_int4_3.ctid
                           Index Cond: (metrics_int4_3."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4 (actual rows=1.00 loops=1)
                           Output: metrics_int4_4."time", metrics_int4_4.tableoid, metrics_int4_4.ctid
                           Index Cond: (metrics_int4_4."time" < length(version()))
               ->  Hash (actual rows=4.00 loops=1)
                     Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                     ->  HashAggregate (actual rows=4.00 loops=1)
                           Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                           Group Key: metrics_int2."time"
                           ->  Append (actual rows=4.00 loops=1)
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_1_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_1.ctid, metrics_int2_1."time", metrics_int2_1.tableoid
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_9_chunk metrics_int2_2 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_2.ctid, metrics_int2_2."time", metrics_int2_2.tableoid
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_17_chunk metrics_int2_3 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_3.ctid, metrics_int2_3."time", metrics_int2_3.tableoid
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_25_chunk metrics_int2_4 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_4.ctid, metrics_int2_4."time", metrics_int2_4.tableoid

ROLLBACK;
BEGIN;
:PREFIX DELETE FROM metrics_int4 WHERE time IN (SELECT time FROM metrics_int2 WHERE time < length(version()));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1
         Delete on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2
         Delete on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3
         Delete on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4
         ->  Hash Join (actual rows=4.00 loops=1)
               Output: metrics_int2.ctid, metrics_int4.tableoid, metrics_int4.ctid, metrics_int2.tableoid
               Inner Unique: true
               Hash Cond: (metrics_int4."time" = metrics_int2."time")
               ->  Append (actual rows=4.00 loops=1)
                     ->  Seq Scan on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1."time", metrics_int4_1.tableoid, metrics_int4_1.ctid
                     ->  Seq Scan on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2 (actual rows=1.00 loops=1)
                           Output: metrics_int4_2."time", metrics_int4_2.tableoid, metrics_int4_2.ctid
                     ->  Seq Scan on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3 (actual rows=1.00 loops=1)
                           Output: metrics_int4_3."time", metrics_int4_3.tableoid, metrics_int4_3.ctid
                     ->  Seq Scan on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4 (actual rows=1.00 loops=1)
                           Output: metrics_int4_4."time", metrics_int4_4.tableoid, metrics_int4_4.ctid
               ->  Hash (actual rows=4.00 loops=1)
                     Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                     ->  HashAggregate (actual rows=4.00 loops=1)
                           Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                           Group Key: metrics_int2."time"
                           ->  Append (actual rows=4.00 loops=1)
                                 ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_1.ctid, metrics_int2_1."time", metrics_int2_1.tableoid
                                       Index Cond: (metrics_int2_1."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk metrics_int2_2 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_2.ctid, metrics_int2_2."time", metrics_int2_2.tableoid
                                       Index Cond: (metrics_int2_2."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_3 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_3.ctid, metrics_int2_3."time", metrics_int2_3.tableoid
                                       Index Cond: (metrics_int2_3."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk metrics_int2_4 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_4.ctid, metrics_int2_4."time", metrics_int2_4.tableoid
                                       Index Cond: (metrics_int2_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX DELETE FROM metrics_int4 WHERE time IN (SELECT time FROM metrics_int2 WHERE time < length(version())) AND time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1
         Delete on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2
         Delete on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3
         Delete on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4
         ->  Hash Join (actual rows=4.00 loops=1)
               Output: metrics_int2.ctid, metrics_int4.tableoid, metrics_int4.ctid, metrics_int2.tableoid
               Inner Unique: true
               Hash Cond: (metrics_int4."time" = metrics_int2."time")
               ->  Append (actual rows=4.00 loops=1)
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1."time", metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2 (actual rows=1.00 loops=1)
                           Output: metrics_int4_2."time", metrics_int4_2.tableoid, metrics_int4_2.ctid
                           Index Cond: (metrics_int4_2."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3 (actual rows=1.00 loops=1)
                           Output: metrics_int4_3."time", metrics_int4_3.tableoid, metrics_int4_3.ctid
                           Index Cond: (metrics_int4_3."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4 (actual rows=1.00 loops=1)
                           Output: metrics_int4_4."time", metrics_int4_4.tableoid, metrics_int4_4.ctid
                           Index Cond: (metrics_int4_4."time" < length(version()))
               ->  Hash (actual rows=4.00 loops=1)
                     Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                     ->  HashAggregate (actual rows=4.00 loops=1)
                           Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                           Group Key: metrics_int2."time"
                           ->  Append (actual rows=4.00 loops=1)
                                 ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_1.ctid, metrics_int2_1."time", metrics_int2_1.tableoid
                                       Index Cond: (metrics_int2_1."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk metrics_int2_2 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_2.ctid, metrics_int2_2."time", metrics_int2_2.tableoid
                                       Index Cond: (metrics_int2_2."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_3 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_3.ctid, metrics_int2_3."time", metrics_int2_3.tableoid
                                       Index Cond: (metrics_int2_3."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk metrics_int2_4 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_4.ctid, metrics_int2_4."time", metrics_int2_4.tableoid
                                       Index Cond: (metrics_int2_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int4 SET value = 0.1 WHERE time IN (SELECT time FROM metrics_int2) AND time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2
         Update on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3
         Update on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4
         ->  Hash Join (actual rows=4.00 loops=1)
               Output: '0.1'::double precision, metrics_int2.ctid, metrics_int4.tableoid, metrics_int4.ctid, metrics_int2.tableoid
               Inner Unique: true
               Hash Cond: (metrics_int4."time" = metrics_int2."time")
               ->  Append (actual rows=4.00 loops=1)
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1."time", metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2 (actual rows=1.00 loops=1)
                           Output: metrics_int4_2."time", metrics_int4_2.tableoid, metrics_int4_2.ctid
                           Index Cond: (metrics_int4_2."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3 (actual rows=1.00 loops=1)
                           Output: metrics_int4_3."time", metrics_int4_3.tableoid, metrics_int4_3.ctid
                           Index Cond: (metrics_int4_3."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4 (actual rows=1.00 loops=1)
                           Output: metrics_int4_4."time", metrics_int4_4.tableoid, metrics_int4_4.ctid
                           Index Cond: (metrics_int4_4."time" < length(version()))
               ->  Hash (actual rows=4.00 loops=1)
                     Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                     ->  HashAggregate (actual rows=4.00 loops=1)
                           Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                           Group Key: metrics_int2."time"
                           ->  Append (actual rows=4.00 loops=1)
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_1_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_1.ctid, metrics_int2_1."time", metrics_int2_1.tableoid
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_9_chunk metrics_int2_2 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_2.ctid, metrics_int2_2."time", metrics_int2_2.tableoid
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_17_chunk metrics_int2_3 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_3.ctid, metrics_int2_3."time", metrics_int2_3.tableoid
                                 ->  Seq Scan on _timescaledb_internal._hyper_1_25_chunk metrics_int2_4 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_4.ctid, metrics_int2_4."time", metrics_int2_4.tableoid

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int4 SET value = 0.1 WHERE time IN (SELECT time FROM metrics_int2 WHERE time < length(version()));
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2
         Update on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3
         Update on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4
         ->  Hash Join (actual rows=4.00 loops=1)
               Output: '0.1'::double precision, metrics_int2.ctid, metrics_int4.tableoid, metrics_int4.ctid, metrics_int2.tableoid
               Inner Unique: true
               Hash Cond: (metrics_int4."time" = metrics_int2."time")
               ->  Append (actual rows=4.00 loops=1)
                     ->  Seq Scan on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1."time", metrics_int4_1.tableoid, metrics_int4_1.ctid
                     ->  Seq Scan on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2 (actual rows=1.00 loops=1)
                           Output: metrics_int4_2."time", metrics_int4_2.tableoid, metrics_int4_2.ctid
                     ->  Seq Scan on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3 (actual rows=1.00 loops=1)
                           Output: metrics_int4_3."time", metrics_int4_3.tableoid, metrics_int4_3.ctid
                     ->  Seq Scan on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4 (actual rows=1.00 loops=1)
                           Output: metrics_int4_4."time", metrics_int4_4.tableoid, metrics_int4_4.ctid
               ->  Hash (actual rows=4.00 loops=1)
                     Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                     ->  HashAggregate (actual rows=4.00 loops=1)
                           Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                           Group Key: metrics_int2."time"
                           ->  Append (actual rows=4.00 loops=1)
                                 ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_1.ctid, metrics_int2_1."time", metrics_int2_1.tableoid
                                       Index Cond: (metrics_int2_1."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk metrics_int2_2 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_2.ctid, metrics_int2_2."time", metrics_int2_2.tableoid
                                       Index Cond: (metrics_int2_2."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_3 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_3.ctid, metrics_int2_3."time", metrics_int2_3.tableoid
                                       Index Cond: (metrics_int2_3."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk metrics_int2_4 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_4.ctid, metrics_int2_4."time", metrics_int2_4.tableoid
                                       Index Cond: (metrics_int2_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int4 SET value = 0.1 WHERE time IN (SELECT time FROM metrics_int2 WHERE time < length(version())) AND time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1
         Update on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2
         Update on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3
         Update on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4
         ->  Hash Join (actual rows=4.00 loops=1)
               Output: '0.1'::double precision, metrics_int2.ctid, metrics_int4.tableoid, metrics_int4.ctid, metrics_int2.tableoid
               Inner Unique: true
               Hash Cond: (metrics_int4."time" = metrics_int2."time")
               ->  Append (actual rows=4.00 loops=1)
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk metrics_int4_1 (actual rows=1.00 loops=1)
                           Output: metrics_int4_1."time", metrics_int4_1.tableoid, metrics_int4_1.ctid
                           Index Cond: (metrics_int4_1."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk metrics_int4_2 (actual rows=1.00 loops=1)
                           Output: metrics_int4_2."time", metrics_int4_2.tableoid, metrics_int4_2.ctid
                           Index Cond: (metrics_int4_2."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk metrics_int4_3 (actual rows=1.00 loops=1)
                           Output: metrics_int4_3."time", metrics_int4_3.tableoid, metrics_int4_3.ctid
                           Index Cond: (metrics_int4_3."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk metrics_int4_4 (actual rows=1.00 loops=1)
                           Output: metrics_int4_4."time", metrics_int4_4.tableoid, metrics_int4_4.ctid
                           Index Cond: (metrics_int4_4."time" < length(version()))
               ->  Hash (actual rows=4.00 loops=1)
                     Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                     ->  HashAggregate (actual rows=4.00 loops=1)
                           Output: metrics_int2.ctid, metrics_int2."time", metrics_int2.tableoid
                           Group Key: metrics_int2."time"
                           ->  Append (actual rows=4.00 loops=1)
                                 ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk metrics_int2_1 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_1.ctid, metrics_int2_1."time", metrics_int2_1.tableoid
                                       Index Cond: (metrics_int2_1."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk metrics_int2_2 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_2.ctid, metrics_int2_2."time", metrics_int2_2.tableoid
                                       Index Cond: (metrics_int2_2."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk metrics_int2_3 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_3.ctid, metrics_int2_3."time", metrics_int2_3.tableoid
                                       Index Cond: (metrics_int2_3."time" < length(version()))
                                 ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk metrics_int2_4 (actual rows=1.00 loops=1)
                                       Output: metrics_int2_4.ctid, metrics_int2_4."time", metrics_int2_4.tableoid
                                       Index Cond: (metrics_int2_4."time" < length(version()))

ROLLBACK;
-- join
-- no chunk exclusion for subqueries joins atm
BEGIN;
:PREFIX DELETE FROM metrics_int4 m4 USING metrics_int2 m2;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 m4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk m4_1
         Delete on _timescaledb_internal._hyper_2_10_chunk m4_2
         Delete on _timescaledb_internal._hyper_2_18_chunk m4_3
         Delete on _timescaledb_internal._hyper_2_26_chunk m4_4
         ->  Nested Loop (actual rows=16.00 loops=1)
               Output: m2.ctid, m4.tableoid, m4.ctid, m2.tableoid
               ->  Append (actual rows=4.00 loops=1)
                     ->  Seq Scan on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                           Output: m2_1.ctid, m2_1.tableoid
                     ->  Seq Scan on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                           Output: m2_2.ctid, m2_2.tableoid
                     ->  Seq Scan on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                           Output: m2_3.ctid, m2_3.tableoid
                     ->  Seq Scan on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                           Output: m2_4.ctid, m2_4.tableoid
               ->  Materialize (actual rows=4.00 loops=4)
                     Output: m4.tableoid, m4.ctid
                     ->  Append (actual rows=4.00 loops=1)
                           ->  Seq Scan on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                                 Output: m4_1.tableoid, m4_1.ctid
                           ->  Seq Scan on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                                 Output: m4_2.tableoid, m4_2.ctid
                           ->  Seq Scan on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                                 Output: m4_3.tableoid, m4_3.ctid
                           ->  Seq Scan on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                                 Output: m4_4.tableoid, m4_4.ctid

ROLLBACK;
BEGIN;
:PREFIX DELETE FROM metrics_int4 m4 USING metrics_int2 m2 WHERE m4.time = m2.time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 m4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk m4_1
         Delete on _timescaledb_internal._hyper_2_10_chunk m4_2
         Delete on _timescaledb_internal._hyper_2_18_chunk m4_3
         Delete on _timescaledb_internal._hyper_2_26_chunk m4_4
         ->  Merge Join (actual rows=4.00 loops=1)
               Output: m2.ctid, m4.tableoid, m4.ctid, m2.tableoid
               Merge Cond: (m4."time" = m2."time")
               ->  Merge Append (actual rows=4.00 loops=1)
                     Sort Key: m4."time"
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                           Output: m4_1."time", m4_1.tableoid, m4_1.ctid
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                           Output: m4_2."time", m4_2.tableoid, m4_2.ctid
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                           Output: m4_3."time", m4_3.tableoid, m4_3.ctid
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                           Output: m4_4."time", m4_4.tableoid, m4_4.ctid
               ->  Materialize (actual rows=4.00 loops=1)
                     Output: m2.ctid, m2."time", m2.tableoid
                     ->  Merge Append (actual rows=4.00 loops=1)
                           Sort Key: m2."time"
                           ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                                 Output: m2_1.ctid, m2_1."time", m2_1.tableoid
                           ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                                 Output: m2_2.ctid, m2_2."time", m2_2.tableoid
                           ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                                 Output: m2_3.ctid, m2_3."time", m2_3.tableoid
                           ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                                 Output: m2_4.ctid, m2_4."time", m2_4.tableoid

ROLLBACK;
BEGIN;
:PREFIX DELETE FROM metrics_int4 m4 USING metrics_int2 m2 WHERE m4.time = m2.time AND m4.time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_int4 m4 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_2_2_chunk m4_1
         Delete on _timescaledb_internal._hyper_2_10_chunk m4_2
         Delete on _timescaledb_internal._hyper_2_18_chunk m4_3
         Delete on _timescaledb_internal._hyper_2_26_chunk m4_4
         ->  Merge Join (actual rows=4.00 loops=1)
               Output: m2.ctid, m4.tableoid, m4.ctid, m2.tableoid
               Merge Cond: (m4."time" = m2."time")
               ->  Merge Append (actual rows=4.00 loops=1)
                     Sort Key: m4."time"
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                           Output: m4_1."time", m4_1.tableoid, m4_1.ctid
                           Index Cond: (m4_1."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                           Output: m4_2."time", m4_2.tableoid, m4_2.ctid
                           Index Cond: (m4_2."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                           Output: m4_3."time", m4_3.tableoid, m4_3.ctid
                           Index Cond: (m4_3."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                           Output: m4_4."time", m4_4.tableoid, m4_4.ctid
                           Index Cond: (m4_4."time" < length(version()))
               ->  Materialize (actual rows=4.00 loops=1)
                     Output: m2.ctid, m2."time", m2.tableoid
                     ->  Merge Append (actual rows=4.00 loops=1)
                           Sort Key: m2."time"
                           ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                                 Output: m2_1.ctid, m2_1."time", m2_1.tableoid
                           ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                                 Output: m2_2.ctid, m2_2."time", m2_2.tableoid
                           ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                                 Output: m2_3.ctid, m2_3."time", m2_3.tableoid
                           ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                                 Output: m2_4.ctid, m2_4."time", m2_4.tableoid

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int4 m4 SET value = 0.15 FROM metrics_int2 m2;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 m4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk m4_1
         Update on _timescaledb_internal._hyper_2_10_chunk m4_2
         Update on _timescaledb_internal._hyper_2_18_chunk m4_3
         Update on _timescaledb_internal._hyper_2_26_chunk m4_4
         ->  Nested Loop (actual rows=16.00 loops=1)
               Output: '0.15'::double precision, m2.ctid, m4.tableoid, m4.ctid, m2.tableoid
               ->  Append (actual rows=4.00 loops=1)
                     ->  Seq Scan on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                           Output: m2_1.ctid, m2_1.tableoid
                     ->  Seq Scan on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                           Output: m2_2.ctid, m2_2.tableoid
                     ->  Seq Scan on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                           Output: m2_3.ctid, m2_3.tableoid
                     ->  Seq Scan on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                           Output: m2_4.ctid, m2_4.tableoid
               ->  Materialize (actual rows=4.00 loops=4)
                     Output: m4.tableoid, m4.ctid
                     ->  Append (actual rows=4.00 loops=1)
                           ->  Seq Scan on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                                 Output: m4_1.tableoid, m4_1.ctid
                           ->  Seq Scan on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                                 Output: m4_2.tableoid, m4_2.ctid
                           ->  Seq Scan on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                                 Output: m4_3.tableoid, m4_3.ctid
                           ->  Seq Scan on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                                 Output: m4_4.tableoid, m4_4.ctid

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int4 m4 SET value = 0.15 FROM metrics_int2 m2 WHERE m4.time = m2.time;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 m4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk m4_1
         Update on _timescaledb_internal._hyper_2_10_chunk m4_2
         Update on _timescaledb_internal._hyper_2_18_chunk m4_3
         Update on _timescaledb_internal._hyper_2_26_chunk m4_4
         ->  Merge Join (actual rows=4.00 loops=1)
               Output: '0.15'::double precision, m2.ctid, m4.tableoid, m4.ctid, m2.tableoid
               Merge Cond: (m4."time" = m2."time")
               ->  Merge Append (actual rows=4.00 loops=1)
                     Sort Key: m4."time"
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                           Output: m4_1."time", m4_1.tableoid, m4_1.ctid
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                           Output: m4_2."time", m4_2.tableoid, m4_2.ctid
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                           Output: m4_3."time", m4_3.tableoid, m4_3.ctid
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                           Output: m4_4."time", m4_4.tableoid, m4_4.ctid
               ->  Materialize (actual rows=4.00 loops=1)
                     Output: m2.ctid, m2."time", m2.tableoid
                     ->  Merge Append (actual rows=4.00 loops=1)
                           Sort Key: m2."time"
                           ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                                 Output: m2_1.ctid, m2_1."time", m2_1.tableoid
                           ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                                 Output: m2_2.ctid, m2_2."time", m2_2.tableoid
                           ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                                 Output: m2_3.ctid, m2_3."time", m2_3.tableoid
                           ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                                 Output: m2_4.ctid, m2_4."time", m2_4.tableoid

ROLLBACK;
BEGIN;
:PREFIX UPDATE metrics_int4 m4 SET value = 0.15 FROM metrics_int2 m2 WHERE m4.time = m2.time AND m4.time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_int4 m4 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_2_2_chunk m4_1
         Update on _timescaledb_internal._hyper_2_10_chunk m4_2
         Update on _timescaledb_internal._hyper_2_18_chunk m4_3
         Update on _timescaledb_internal._hyper_2_26_chunk m4_4
         ->  Merge Join (actual rows=4.00 loops=1)
               Output: '0.15'::double precision, m2.ctid, m4.tableoid, m4.ctid, m2.tableoid
               Merge Cond: (m4."time" = m2."time")
               ->  Merge Append (actual rows=4.00 loops=1)
                     Sort Key: m4."time"
                     ->  Index Scan Backward using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                           Output: m4_1."time", m4_1.tableoid, m4_1.ctid
                           Index Cond: (m4_1."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                           Output: m4_2."time", m4_2.tableoid, m4_2.ctid
                           Index Cond: (m4_2."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                           Output: m4_3."time", m4_3.tableoid, m4_3.ctid
                           Index Cond: (m4_3."time" < length(version()))
                     ->  Index Scan Backward using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                           Output: m4_4."time", m4_4.tableoid, m4_4.ctid
                           Index Cond: (m4_4."time" < length(version()))
               ->  Materialize (actual rows=4.00 loops=1)
                     Output: m2.ctid, m2."time", m2.tableoid
                     ->  Merge Append (actual rows=4.00 loops=1)
                           Sort Key: m2."time"
                           ->  Index Scan Backward using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                                 Output: m2_1.ctid, m2_1."time", m2_1.tableoid
                           ->  Index Scan Backward using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                                 Output: m2_2.ctid, m2_2."time", m2_2.tableoid
                           ->  Index Scan Backward using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                                 Output: m2_3.ctid, m2_3."time", m2_3.tableoid
                           ->  Index Scan Backward using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                                 Output: m2_4.ctid, m2_4."time", m2_4.tableoid

ROLLBACK;
-- cte
-- should all have chunkappend nodes
BEGIN;
:PREFIX WITH d AS (DELETE FROM metrics_int4 m4 WHERE m4.time < length(version()) RETURNING time)
SELECT * FROM d;
--- QUERY PLAN ---
 CTE Scan on d (actual rows=4.00 loops=1)
   Output: d."time"
   CTE d
     ->  Custom Scan (ModifyHypertable) (actual rows=4.00 loops=1)
           Output: m4_1."time"
           ->  Delete on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                 Output: m4_1."time"
                 Delete on _timescaledb_internal._hyper_2_2_chunk m4_1
                 Delete on _timescaledb_internal._hyper_2_10_chunk m4_2
                 Delete on _timescaledb_internal._hyper_2_18_chunk m4_3
                 Delete on _timescaledb_internal._hyper_2_26_chunk m4_4
                 ->  Custom Scan (ChunkAppend) on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                       Startup Exclusion: true
                       Runtime Exclusion: false
                       Chunks excluded during startup: 0
                       ->  Index Scan using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                             Output: m4_1.tableoid, m4_1.ctid
                             Index Cond: (m4_1."time" < length(version()))
                       ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                             Output: m4_2.tableoid, m4_2.ctid
                             Index Cond: (m4_2."time" < length(version()))
                       ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                             Output: m4_3.tableoid, m4_3.ctid
                             Index Cond: (m4_3."time" < length(version()))
                       ->  Index Scan using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                             Output: m4_4.tableoid, m4_4.ctid
                             Index Cond: (m4_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX WITH d AS (DELETE FROM metrics_int4 m4 WHERE m4.time < length(version()))
DELETE FROM metrics_int2 m2 WHERE m2.time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   CTE d
     ->  Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
           ->  Delete on public.metrics_int4 m4 (actual rows=0.00 loops=1)
                 Delete on _timescaledb_internal._hyper_2_2_chunk m4_1
                 Delete on _timescaledb_internal._hyper_2_10_chunk m4_2
                 Delete on _timescaledb_internal._hyper_2_18_chunk m4_3
                 Delete on _timescaledb_internal._hyper_2_26_chunk m4_4
                 ->  Custom Scan (ChunkAppend) on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                       Startup Exclusion: true
                       Runtime Exclusion: false
                       Chunks excluded during startup: 0
                       ->  Index Scan using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                             Output: m4_1.tableoid, m4_1.ctid
                             Index Cond: (m4_1."time" < length(version()))
                       ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                             Output: m4_2.tableoid, m4_2.ctid
                             Index Cond: (m4_2."time" < length(version()))
                       ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                             Output: m4_3.tableoid, m4_3.ctid
                             Index Cond: (m4_3."time" < length(version()))
                       ->  Index Scan using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                             Output: m4_4.tableoid, m4_4.ctid
                             Index Cond: (m4_4."time" < length(version()))
   ->  Delete on public.metrics_int2 m2 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_1_1_chunk m2_1
         Delete on _timescaledb_internal._hyper_1_9_chunk m2_2
         Delete on _timescaledb_internal._hyper_1_17_chunk m2_3
         Delete on _timescaledb_internal._hyper_1_25_chunk m2_4
         ->  Custom Scan (ChunkAppend) on public.metrics_int2 m2 (actual rows=4.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 0
               ->  Index Scan using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                     Output: m2_1.tableoid, m2_1.ctid
                     Index Cond: (m2_1."time" < length(version()))
               ->  Index Scan using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                     Output: m2_2.tableoid, m2_2.ctid
                     Index Cond: (m2_2."time" < length(version()))
               ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                     Output: m2_3.tableoid, m2_3.ctid
                     Index Cond: (m2_3."time" < length(version()))
               ->  Index Scan using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                     Output: m2_4.tableoid, m2_4.ctid
                     Index Cond: (m2_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX WITH u AS (UPDATE metrics_int4 m4 SET data = 'cte update' WHERE m4.time < length(version()) RETURNING time)
SELECT * FROM u;
--- QUERY PLAN ---
 CTE Scan on u (actual rows=4.00 loops=1)
   Output: u."time"
   CTE u
     ->  Custom Scan (ModifyHypertable) (actual rows=4.00 loops=1)
           Output: m4_1."time"
           ->  Update on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                 Output: m4_1."time"
                 Update on _timescaledb_internal._hyper_2_2_chunk m4_1
                 Update on _timescaledb_internal._hyper_2_10_chunk m4_2
                 Update on _timescaledb_internal._hyper_2_18_chunk m4_3
                 Update on _timescaledb_internal._hyper_2_26_chunk m4_4
                 ->  Result (actual rows=4.00 loops=1)
                       Output: 'cte update'::text, m4.tableoid, m4.ctid
                       ->  Custom Scan (ChunkAppend) on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                             Output: m4.tableoid, m4.ctid
                             Startup Exclusion: true
                             Runtime Exclusion: false
                             Chunks excluded during startup: 0
                             ->  Index Scan using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                                   Output: m4_1.tableoid, m4_1.ctid
                                   Index Cond: (m4_1."time" < length(version()))
                             ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                                   Output: m4_2.tableoid, m4_2.ctid
                                   Index Cond: (m4_2."time" < length(version()))
                             ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                                   Output: m4_3.tableoid, m4_3.ctid
                                   Index Cond: (m4_3."time" < length(version()))
                             ->  Index Scan using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                                   Output: m4_4.tableoid, m4_4.ctid
                                   Index Cond: (m4_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX WITH u AS (UPDATE metrics_int4 m4 SET data = 'cte update 1' WHERE m4.time < length(version()))
UPDATE metrics_int2 m2 SET data = 'cte update 2' WHERE m2.time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   CTE u
     ->  Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
           ->  Update on public.metrics_int4 m4 (actual rows=0.00 loops=1)
                 Update on _timescaledb_internal._hyper_2_2_chunk m4_1
                 Update on _timescaledb_internal._hyper_2_10_chunk m4_2
                 Update on _timescaledb_internal._hyper_2_18_chunk m4_3
                 Update on _timescaledb_internal._hyper_2_26_chunk m4_4
                 ->  Result (actual rows=4.00 loops=1)
                       Output: 'cte update 1'::text, m4.tableoid, m4.ctid
                       ->  Custom Scan (ChunkAppend) on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                             Output: m4.tableoid, m4.ctid
                             Startup Exclusion: true
                             Runtime Exclusion: false
                             Chunks excluded during startup: 0
                             ->  Index Scan using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                                   Output: m4_1.tableoid, m4_1.ctid
                                   Index Cond: (m4_1."time" < length(version()))
                             ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                                   Output: m4_2.tableoid, m4_2.ctid
                                   Index Cond: (m4_2."time" < length(version()))
                             ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                                   Output: m4_3.tableoid, m4_3.ctid
                                   Index Cond: (m4_3."time" < length(version()))
                             ->  Index Scan using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                                   Output: m4_4.tableoid, m4_4.ctid
                                   Index Cond: (m4_4."time" < length(version()))
   ->  Update on public.metrics_int2 m2 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_1_1_chunk m2_1
         Update on _timescaledb_internal._hyper_1_9_chunk m2_2
         Update on _timescaledb_internal._hyper_1_17_chunk m2_3
         Update on _timescaledb_internal._hyper_1_25_chunk m2_4
         ->  Result (actual rows=4.00 loops=1)
               Output: 'cte update 2'::text, m2.tableoid, m2.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int2 m2 (actual rows=4.00 loops=1)
                     Output: m2.tableoid, m2.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 0
                     ->  Index Scan using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                           Output: m2_1.tableoid, m2_1.ctid
                           Index Cond: (m2_1."time" < length(version()))
                     ->  Index Scan using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                           Output: m2_2.tableoid, m2_2.ctid
                           Index Cond: (m2_2."time" < length(version()))
                     ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                           Output: m2_3.tableoid, m2_3.ctid
                           Index Cond: (m2_3."time" < length(version()))
                     ->  Index Scan using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                           Output: m2_4.tableoid, m2_4.ctid
                           Index Cond: (m2_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX WITH d AS (DELETE FROM metrics_int4 m4 WHERE m4.time < length(version()) RETURNING time)
UPDATE metrics_int2 m2 SET data = 'cte update' WHERE m2.time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   CTE d
     ->  Custom Scan (ModifyHypertable) (actual rows=4.00 loops=1)
           Output: m4_1."time"
           ->  Delete on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                 Output: m4_1."time"
                 Delete on _timescaledb_internal._hyper_2_2_chunk m4_1
                 Delete on _timescaledb_internal._hyper_2_10_chunk m4_2
                 Delete on _timescaledb_internal._hyper_2_18_chunk m4_3
                 Delete on _timescaledb_internal._hyper_2_26_chunk m4_4
                 ->  Custom Scan (ChunkAppend) on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                       Startup Exclusion: true
                       Runtime Exclusion: false
                       Chunks excluded during startup: 0
                       ->  Index Scan using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                             Output: m4_1.tableoid, m4_1.ctid
                             Index Cond: (m4_1."time" < length(version()))
                       ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                             Output: m4_2.tableoid, m4_2.ctid
                             Index Cond: (m4_2."time" < length(version()))
                       ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                             Output: m4_3.tableoid, m4_3.ctid
                             Index Cond: (m4_3."time" < length(version()))
                       ->  Index Scan using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                             Output: m4_4.tableoid, m4_4.ctid
                             Index Cond: (m4_4."time" < length(version()))
   ->  Update on public.metrics_int2 m2 (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_1_1_chunk m2_1
         Update on _timescaledb_internal._hyper_1_9_chunk m2_2
         Update on _timescaledb_internal._hyper_1_17_chunk m2_3
         Update on _timescaledb_internal._hyper_1_25_chunk m2_4
         ->  Result (actual rows=4.00 loops=1)
               Output: 'cte update'::text, m2.tableoid, m2.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_int2 m2 (actual rows=4.00 loops=1)
                     Output: m2.tableoid, m2.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 0
                     ->  Index Scan using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                           Output: m2_1.tableoid, m2_1.ctid
                           Index Cond: (m2_1."time" < length(version()))
                     ->  Index Scan using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                           Output: m2_2.tableoid, m2_2.ctid
                           Index Cond: (m2_2."time" < length(version()))
                     ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                           Output: m2_3.tableoid, m2_3.ctid
                           Index Cond: (m2_3."time" < length(version()))
                     ->  Index Scan using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                           Output: m2_4.tableoid, m2_4.ctid
                           Index Cond: (m2_4."time" < length(version()))

ROLLBACK;
BEGIN;
:PREFIX WITH u AS (UPDATE metrics_int4 m4 SET data = 'cte update' WHERE m4.time < length(version()) RETURNING time)
DELETE FROM metrics_int2 m2 WHERE m2.time < length(version());
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   CTE u
     ->  Custom Scan (ModifyHypertable) (actual rows=4.00 loops=1)
           Output: m4_1."time"
           ->  Update on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                 Output: m4_1."time"
                 Update on _timescaledb_internal._hyper_2_2_chunk m4_1
                 Update on _timescaledb_internal._hyper_2_10_chunk m4_2
                 Update on _timescaledb_internal._hyper_2_18_chunk m4_3
                 Update on _timescaledb_internal._hyper_2_26_chunk m4_4
                 ->  Result (actual rows=4.00 loops=1)
                       Output: 'cte update'::text, m4.tableoid, m4.ctid
                       ->  Custom Scan (ChunkAppend) on public.metrics_int4 m4 (actual rows=4.00 loops=1)
                             Output: m4.tableoid, m4.ctid
                             Startup Exclusion: true
                             Runtime Exclusion: false
                             Chunks excluded during startup: 0
                             ->  Index Scan using _hyper_2_2_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_2_chunk m4_1 (actual rows=1.00 loops=1)
                                   Output: m4_1.tableoid, m4_1.ctid
                                   Index Cond: (m4_1."time" < length(version()))
                             ->  Index Scan using _hyper_2_10_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_10_chunk m4_2 (actual rows=1.00 loops=1)
                                   Output: m4_2.tableoid, m4_2.ctid
                                   Index Cond: (m4_2."time" < length(version()))
                             ->  Index Scan using _hyper_2_18_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_18_chunk m4_3 (actual rows=1.00 loops=1)
                                   Output: m4_3.tableoid, m4_3.ctid
                                   Index Cond: (m4_3."time" < length(version()))
                             ->  Index Scan using _hyper_2_26_chunk_metrics_int4_time_idx on _timescaledb_internal._hyper_2_26_chunk m4_4 (actual rows=1.00 loops=1)
                                   Output: m4_4.tableoid, m4_4.ctid
                                   Index Cond: (m4_4."time" < length(version()))
   ->  Delete on public.metrics_int2 m2 (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_1_1_chunk m2_1
         Delete on _timescaledb_internal._hyper_1_9_chunk m2_2
         Delete on _timescaledb_internal._hyper_1_17_chunk m2_3
         Delete on _timescaledb_internal._hyper_1_25_chunk m2_4
         ->  Custom Scan (ChunkAppend) on public.metrics_int2 m2 (actual rows=4.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 0
               ->  Index Scan using _hyper_1_1_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_1_chunk m2_1 (actual rows=1.00 loops=1)
                     Output: m2_1.tableoid, m2_1.ctid
                     Index Cond: (m2_1."time" < length(version()))
               ->  Index Scan using _hyper_1_9_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_9_chunk m2_2 (actual rows=1.00 loops=1)
                     Output: m2_2.tableoid, m2_2.ctid
                     Index Cond: (m2_2."time" < length(version()))
               ->  Index Scan using _hyper_1_17_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_17_chunk m2_3 (actual rows=1.00 loops=1)
                     Output: m2_3.tableoid, m2_3.ctid
                     Index Cond: (m2_3."time" < length(version()))
               ->  Index Scan using _hyper_1_25_chunk_metrics_int2_time_idx on _timescaledb_internal._hyper_1_25_chunk m2_4 (actual rows=1.00 loops=1)
                     Output: m2_4.tableoid, m2_4.ctid
                     Index Cond: (m2_4."time" < length(version()))

ROLLBACK;
-- test interaction with compression
-- with chunk exclusion for compressed chunks operations that would
-- error because they hit compressed chunks before can succeed now
-- if those chunks get excluded
-- delete from uncompressed chunks with non-immutable constraints
BEGIN;
:PREFIX DELETE FROM metrics_compressed WHERE time > '2005-01-01'::text::timestamptz;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Delete on public.metrics_compressed (actual rows=0.00 loops=1)
         Delete on _timescaledb_internal._hyper_8_33_chunk metrics_compressed
         Delete on _timescaledb_internal._hyper_8_35_chunk metrics_compressed_1
         Delete on _timescaledb_internal._hyper_8_36_chunk metrics_compressed_2
         Delete on _timescaledb_internal._hyper_8_37_chunk metrics_compressed_3
         ->  Custom Scan (ChunkAppend) on public.metrics_compressed (actual rows=3.00 loops=1)
               Startup Exclusion: true
               Runtime Exclusion: false
               Chunks excluded during startup: 1
               ->  Index Scan using _hyper_8_35_chunk_metrics_compressed_time_idx on _timescaledb_internal._hyper_8_35_chunk metrics_compressed_1 (actual rows=1.00 loops=1)
                     Output: metrics_compressed_1.tableoid, metrics_compressed_1.ctid
                     Index Cond: (metrics_compressed_1."time" > ('2005-01-01'::cstring)::timestamp with time zone)
               ->  Index Scan using _hyper_8_36_chunk_metrics_compressed_time_idx on _timescaledb_internal._hyper_8_36_chunk metrics_compressed_2 (actual rows=1.00 loops=1)
                     Output: metrics_compressed_2.tableoid, metrics_compressed_2.ctid
                     Index Cond: (metrics_compressed_2."time" > ('2005-01-01'::cstring)::timestamp with time zone)
               ->  Index Scan using _hyper_8_37_chunk_metrics_compressed_time_idx on _timescaledb_internal._hyper_8_37_chunk metrics_compressed_3 (actual rows=1.00 loops=1)
                     Output: metrics_compressed_3.tableoid, metrics_compressed_3.ctid
                     Index Cond: (metrics_compressed_3."time" > ('2005-01-01'::cstring)::timestamp with time zone)

ROLLBACK;
-- update uncompressed chunks with non-immutable constraints
BEGIN;
:PREFIX UPDATE metrics_compressed SET value = 2 * value WHERE time > '2005-01-01'::text::timestamptz;
--- QUERY PLAN ---
 Custom Scan (ModifyHypertable) (actual rows=0.00 loops=1)
   ->  Update on public.metrics_compressed (actual rows=0.00 loops=1)
         Update on _timescaledb_internal._hyper_8_33_chunk metrics_compressed
         Update on _timescaledb_internal._hyper_8_35_chunk metrics_compressed_1
         Update on _timescaledb_internal._hyper_8_36_chunk metrics_compressed_2
         Update on _timescaledb_internal._hyper_8_37_chunk metrics_compressed_3
         ->  Result (actual rows=3.00 loops=1)
               Output: ('2'::double precision * metrics_compressed.value), metrics_compressed.tableoid, metrics_compressed.ctid
               ->  Custom Scan (ChunkAppend) on public.metrics_compressed (actual rows=3.00 loops=1)
                     Output: metrics_compressed.value, metrics_compressed.tableoid, metrics_compressed.ctid
                     Startup Exclusion: true
                     Runtime Exclusion: false
                     Chunks excluded during startup: 1
                     ->  Index Scan using _hyper_8_35_chunk_metrics_compressed_time_idx on _timescaledb_internal._hyper_8_35_chunk metrics_compressed_1 (actual rows=1.00 loops=1)
                           Output: metrics_compressed_1.value, metrics_compressed_1.tableoid, metrics_compressed_1.ctid
                           Index Cond: (metrics_compressed_1."time" > ('2005-01-01'::cstring)::timestamp with time zone)
                     ->  Index Scan using _hyper_8_36_chunk_metrics_compressed_time_idx on _timescaledb_internal._hyper_8_36_chunk metrics_compressed_2 (actual rows=1.00 loops=1)
                           Output: metrics_compressed_2.value, metrics_compressed_2.tableoid, metrics_compressed_2.ctid
                           Index Cond: (metrics_compressed_2."time" > ('2005-01-01'::cstring)::timestamp with time zone)
                     ->  Index Scan using _hyper_8_37_chunk_metrics_compressed_time_idx on _timescaledb_internal._hyper_8_37_chunk metrics_compressed_3 (actual rows=1.00 loops=1)
                           Output: metrics_compressed_3.value, metrics_compressed_3.tableoid, metrics_compressed_3.ctid
                           Index Cond: (metrics_compressed_3."time" > ('2005-01-01'::cstring)::timestamp with time zone)

ROLLBACK;
