mirror of https://github.com/citusdata/citus.git
Update ordering on test and add new one for create_missing_partitions
parent
dfdda48cbf
commit
7a4293fe37
|
@ -0,0 +1,646 @@
|
||||||
|
-- Show get_missing_partition_ranges function can be only callede for timeseries tables
|
||||||
|
CREATE TABLE date_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdate date,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdate);
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15 days');
|
||||||
|
ERROR: date_partitioned_table must be timeseries table
|
||||||
|
CONTEXT: PL/pgSQL function get_missing_partition_ranges(regclass,timestamp with time zone,timestamp with time zone) line XX at RAISE
|
||||||
|
PL/pgSQL function create_missing_partitions(regclass,timestamp with time zone,timestamp with time zone) line 22 at FOR over SELECT rows
|
||||||
|
-- Create missing partitions for various ranges on date partitioned table
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 15 days ago | @ 16 days ago
|
||||||
|
@ 14 days ago | @ 15 days ago
|
||||||
|
@ 13 days ago | @ 14 days ago
|
||||||
|
@ 12 days ago | @ 13 days ago
|
||||||
|
@ 11 days ago | @ 12 days ago
|
||||||
|
@ 10 days ago | @ 11 days ago
|
||||||
|
@ 9 days ago | @ 10 days ago
|
||||||
|
@ 8 days ago | @ 9 days ago
|
||||||
|
@ 7 days ago | @ 8 days ago
|
||||||
|
@ 6 days ago | @ 7 days ago
|
||||||
|
@ 5 days ago | @ 6 days ago
|
||||||
|
@ 4 days ago | @ 5 days ago
|
||||||
|
@ 3 days ago | @ 4 days ago
|
||||||
|
@ 2 days ago | @ 3 days ago
|
||||||
|
@ 1 day ago | @ 2 days ago
|
||||||
|
@ 0 | @ 1 day ago
|
||||||
|
@ 1 day | @ 0
|
||||||
|
@ 2 days | @ 1 day
|
||||||
|
@ 3 days | @ 2 days
|
||||||
|
@ 4 days | @ 3 days
|
||||||
|
@ 5 days | @ 4 days
|
||||||
|
@ 6 days | @ 5 days
|
||||||
|
@ 7 days | @ 6 days
|
||||||
|
(23 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '10 days', now() + INTERVAL '10 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 10 days ago | @ 11 days ago
|
||||||
|
@ 9 days ago | @ 10 days ago
|
||||||
|
@ 8 days ago | @ 9 days ago
|
||||||
|
@ 7 days ago | @ 8 days ago
|
||||||
|
@ 6 days ago | @ 7 days ago
|
||||||
|
@ 5 days ago | @ 6 days ago
|
||||||
|
@ 4 days ago | @ 5 days ago
|
||||||
|
@ 3 days ago | @ 4 days ago
|
||||||
|
@ 2 days ago | @ 3 days ago
|
||||||
|
@ 1 day ago | @ 2 days ago
|
||||||
|
@ 0 | @ 1 day ago
|
||||||
|
@ 1 day | @ 0
|
||||||
|
@ 2 days | @ 1 day
|
||||||
|
@ 3 days | @ 2 days
|
||||||
|
@ 4 days | @ 3 days
|
||||||
|
@ 5 days | @ 4 days
|
||||||
|
@ 6 days | @ 5 days
|
||||||
|
@ 7 days | @ 6 days
|
||||||
|
(18 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '45 days', now() + INTERVAL '45 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 45 days ago | @ 50 days ago
|
||||||
|
@ 40 days ago | @ 45 days ago
|
||||||
|
@ 35 days ago | @ 40 days ago
|
||||||
|
@ 30 days ago | @ 35 days ago
|
||||||
|
@ 25 days ago | @ 30 days ago
|
||||||
|
@ 20 days ago | @ 25 days ago
|
||||||
|
@ 15 days ago | @ 20 days ago
|
||||||
|
@ 10 days ago | @ 15 days ago
|
||||||
|
@ 5 days ago | @ 10 days ago
|
||||||
|
@ 0 | @ 5 days ago
|
||||||
|
@ 5 days | @ 0
|
||||||
|
@ 10 days | @ 5 days
|
||||||
|
@ 15 days | @ 10 days
|
||||||
|
@ 20 days | @ 15 days
|
||||||
|
@ 25 days | @ 20 days
|
||||||
|
@ 30 days | @ 25 days
|
||||||
|
@ 35 days | @ 30 days
|
||||||
|
(17 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '65 days', now() + INTERVAL '65 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 60 days ago | @ 67 days ago
|
||||||
|
@ 53 days ago | @ 60 days ago
|
||||||
|
@ 46 days ago | @ 53 days ago
|
||||||
|
@ 39 days ago | @ 46 days ago
|
||||||
|
@ 32 days ago | @ 39 days ago
|
||||||
|
@ 25 days ago | @ 32 days ago
|
||||||
|
@ 18 days ago | @ 25 days ago
|
||||||
|
@ 11 days ago | @ 18 days ago
|
||||||
|
@ 4 days ago | @ 11 days ago
|
||||||
|
@ 3 days | @ 4 days ago
|
||||||
|
@ 10 days | @ 3 days
|
||||||
|
@ 17 days | @ 10 days
|
||||||
|
@ 24 days | @ 17 days
|
||||||
|
@ 31 days | @ 24 days
|
||||||
|
@ 38 days | @ 31 days
|
||||||
|
@ 45 days | @ 38 days
|
||||||
|
@ 52 days | @ 45 days
|
||||||
|
(17 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '5 days', now() + INTERVAL '5 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 7 days ago | @ 8 days ago
|
||||||
|
@ 6 days ago | @ 7 days ago
|
||||||
|
@ 5 days ago | @ 6 days ago
|
||||||
|
@ 4 days ago | @ 5 days ago
|
||||||
|
@ 3 days ago | @ 4 days ago
|
||||||
|
@ 2 days ago | @ 3 days ago
|
||||||
|
@ 1 day ago | @ 2 days ago
|
||||||
|
@ 0 | @ 1 day ago
|
||||||
|
@ 1 day | @ 0
|
||||||
|
@ 2 days | @ 1 day
|
||||||
|
@ 3 days | @ 2 days
|
||||||
|
@ 4 days | @ 3 days
|
||||||
|
@ 5 days | @ 4 days
|
||||||
|
@ 6 days | @ 5 days
|
||||||
|
@ 7 days | @ 6 days
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
DROP TABLE date_partitioned_table;
|
||||||
|
-- Create missing partitions for various ranges on timestamptz partitioned table
|
||||||
|
CREATE TABLE tstz_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdatetime timestamp with time zone,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
|
@ 7 hours ago | @ 8 hours ago
|
||||||
|
@ 6 hours ago | @ 7 hours ago
|
||||||
|
@ 5 hours ago | @ 6 hours ago
|
||||||
|
@ 4 hours ago | @ 5 hours ago
|
||||||
|
@ 3 hours ago | @ 4 hours ago
|
||||||
|
@ 2 hours ago | @ 3 hours ago
|
||||||
|
@ 1 hour ago | @ 2 hours ago
|
||||||
|
@ 0 | @ 1 hour ago
|
||||||
|
@ 1 hour | @ 0
|
||||||
|
@ 2 hours | @ 1 hour
|
||||||
|
@ 3 hours | @ 2 hours
|
||||||
|
@ 4 hours | @ 3 hours
|
||||||
|
@ 5 hours | @ 4 hours
|
||||||
|
@ 6 hours | @ 5 hours
|
||||||
|
@ 7 hours | @ 6 hours
|
||||||
|
(32 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
|
@ 7 hours ago | @ 8 hours ago
|
||||||
|
@ 6 hours ago | @ 7 hours ago
|
||||||
|
@ 5 hours ago | @ 6 hours ago
|
||||||
|
@ 4 hours ago | @ 5 hours ago
|
||||||
|
@ 3 hours ago | @ 4 hours ago
|
||||||
|
@ 2 hours ago | @ 3 hours ago
|
||||||
|
@ 1 hour ago | @ 2 hours ago
|
||||||
|
@ 0 | @ 1 hour ago
|
||||||
|
@ 1 hour | @ 0
|
||||||
|
@ 2 hours | @ 1 hour
|
||||||
|
@ 3 hours | @ 2 hours
|
||||||
|
@ 4 hours | @ 3 hours
|
||||||
|
@ 5 hours | @ 4 hours
|
||||||
|
@ 6 hours | @ 5 hours
|
||||||
|
@ 7 hours | @ 6 hours
|
||||||
|
@ 8 hours | @ 7 hours
|
||||||
|
@ 9 hours | @ 8 hours
|
||||||
|
@ 10 hours | @ 9 hours
|
||||||
|
@ 11 hours | @ 10 hours
|
||||||
|
@ 12 hours | @ 11 hours
|
||||||
|
@ 13 hours | @ 12 hours
|
||||||
|
@ 14 hours | @ 13 hours
|
||||||
|
@ 15 hours | @ 14 hours
|
||||||
|
@ 16 hours | @ 15 hours
|
||||||
|
@ 17 hours | @ 16 hours
|
||||||
|
@ 18 hours | @ 17 hours
|
||||||
|
@ 19 hours | @ 18 hours
|
||||||
|
@ 20 hours | @ 19 hours
|
||||||
|
@ 21 hours | @ 20 hours
|
||||||
|
@ 22 hours | @ 21 hours
|
||||||
|
@ 23 hours | @ 22 hours
|
||||||
|
@ 1 day | @ 23 hours
|
||||||
|
(49 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '6 hours');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 1 day 18 hours ago | @ 2 days ago
|
||||||
|
@ 1 day 12 hours ago | @ 1 day 18 hours ago
|
||||||
|
@ 1 day 6 hours ago | @ 1 day 12 hours ago
|
||||||
|
@ 1 day ago | @ 1 day 6 hours ago
|
||||||
|
@ 18 hours ago | @ 1 day ago
|
||||||
|
@ 12 hours ago | @ 18 hours ago
|
||||||
|
@ 6 hours ago | @ 12 hours ago
|
||||||
|
@ 0 | @ 6 hours ago
|
||||||
|
@ 6 hours | @ 0
|
||||||
|
@ 12 hours | @ 6 hours
|
||||||
|
@ 18 hours | @ 12 hours
|
||||||
|
@ 1 day | @ 18 hours
|
||||||
|
@ 1 day 6 hours | @ 1 day
|
||||||
|
@ 1 day 12 hours | @ 1 day 6 hours
|
||||||
|
@ 1 day 18 hours | @ 1 day 12 hours
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 6 days | @ 5 days
|
||||||
|
@ 1 day ago | @ 2 days ago
|
||||||
|
@ 3 days | @ 2 days
|
||||||
|
@ 4 days ago | @ 5 days ago
|
||||||
|
@ 5 days | @ 4 days
|
||||||
|
@ 2 days ago | @ 3 days ago
|
||||||
|
@ 4 days | @ 3 days
|
||||||
|
@ 3 days ago | @ 4 days ago
|
||||||
|
@ 7 days | @ 6 days
|
||||||
|
@ 0 | @ 1 day ago
|
||||||
|
@ 7 days ago | @ 8 days ago
|
||||||
|
@ 2 days | @ 1 day
|
||||||
|
@ 5 days ago | @ 6 days ago
|
||||||
|
@ 1 day | @ 0
|
||||||
|
@ 6 days ago | @ 7 days ago
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
DROP TABLE tstz_partitioned_table;
|
||||||
|
-- Show range values for timestamp without time zone partitioned table
|
||||||
|
CREATE TABLE tswtz_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdatetime timestamp without time zone,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
|
@ 7 hours ago | @ 8 hours ago
|
||||||
|
@ 6 hours ago | @ 7 hours ago
|
||||||
|
@ 5 hours ago | @ 6 hours ago
|
||||||
|
@ 4 hours ago | @ 5 hours ago
|
||||||
|
@ 3 hours ago | @ 4 hours ago
|
||||||
|
@ 2 hours ago | @ 3 hours ago
|
||||||
|
@ 1 hour ago | @ 2 hours ago
|
||||||
|
@ 0 | @ 1 hour ago
|
||||||
|
@ 1 hour | @ 0
|
||||||
|
@ 2 hours | @ 1 hour
|
||||||
|
@ 3 hours | @ 2 hours
|
||||||
|
@ 4 hours | @ 3 hours
|
||||||
|
@ 5 hours | @ 4 hours
|
||||||
|
@ 6 hours | @ 5 hours
|
||||||
|
@ 7 hours | @ 6 hours
|
||||||
|
(32 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
|
@ 7 hours ago | @ 8 hours ago
|
||||||
|
@ 6 hours ago | @ 7 hours ago
|
||||||
|
@ 5 hours ago | @ 6 hours ago
|
||||||
|
@ 4 hours ago | @ 5 hours ago
|
||||||
|
@ 3 hours ago | @ 4 hours ago
|
||||||
|
@ 2 hours ago | @ 3 hours ago
|
||||||
|
@ 1 hour ago | @ 2 hours ago
|
||||||
|
@ 0 | @ 1 hour ago
|
||||||
|
@ 1 hour | @ 0
|
||||||
|
@ 2 hours | @ 1 hour
|
||||||
|
@ 3 hours | @ 2 hours
|
||||||
|
@ 4 hours | @ 3 hours
|
||||||
|
@ 5 hours | @ 4 hours
|
||||||
|
@ 6 hours | @ 5 hours
|
||||||
|
@ 7 hours | @ 6 hours
|
||||||
|
@ 8 hours | @ 7 hours
|
||||||
|
@ 9 hours | @ 8 hours
|
||||||
|
@ 10 hours | @ 9 hours
|
||||||
|
@ 11 hours | @ 10 hours
|
||||||
|
@ 12 hours | @ 11 hours
|
||||||
|
@ 13 hours | @ 12 hours
|
||||||
|
@ 14 hours | @ 13 hours
|
||||||
|
@ 15 hours | @ 14 hours
|
||||||
|
@ 16 hours | @ 15 hours
|
||||||
|
@ 17 hours | @ 16 hours
|
||||||
|
@ 18 hours | @ 17 hours
|
||||||
|
@ 19 hours | @ 18 hours
|
||||||
|
@ 20 hours | @ 19 hours
|
||||||
|
@ 21 hours | @ 20 hours
|
||||||
|
@ 22 hours | @ 21 hours
|
||||||
|
@ 23 hours | @ 22 hours
|
||||||
|
@ 1 day | @ 23 hours
|
||||||
|
(49 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 1 day 18 hours ago | @ 2 days ago
|
||||||
|
@ 1 day 12 hours ago | @ 1 day 18 hours ago
|
||||||
|
@ 1 day 6 hours ago | @ 1 day 12 hours ago
|
||||||
|
@ 1 day ago | @ 1 day 6 hours ago
|
||||||
|
@ 18 hours ago | @ 1 day ago
|
||||||
|
@ 12 hours ago | @ 18 hours ago
|
||||||
|
@ 6 hours ago | @ 12 hours ago
|
||||||
|
@ 0 | @ 6 hours ago
|
||||||
|
@ 6 hours | @ 0
|
||||||
|
@ 12 hours | @ 6 hours
|
||||||
|
@ 18 hours | @ 12 hours
|
||||||
|
@ 1 day | @ 18 hours
|
||||||
|
@ 1 day 6 hours | @ 1 day
|
||||||
|
@ 1 day 12 hours | @ 1 day 6 hours
|
||||||
|
@ 1 day 18 hours | @ 1 day 12 hours
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day');
|
||||||
|
create_timeseries_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
||||||
|
create_missing_partitions
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
from_diff | to_diff
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
@ 7 days ago | @ 8 days ago
|
||||||
|
@ 6 days ago | @ 7 days ago
|
||||||
|
@ 5 days ago | @ 6 days ago
|
||||||
|
@ 4 days ago | @ 5 days ago
|
||||||
|
@ 3 days ago | @ 4 days ago
|
||||||
|
@ 2 days ago | @ 3 days ago
|
||||||
|
@ 1 day ago | @ 2 days ago
|
||||||
|
@ 0 | @ 1 day ago
|
||||||
|
@ 1 day | @ 0
|
||||||
|
@ 2 days | @ 1 day
|
||||||
|
@ 3 days | @ 2 days
|
||||||
|
@ 4 days | @ 3 days
|
||||||
|
@ 5 days | @ 4 days
|
||||||
|
@ 6 days | @ 5 days
|
||||||
|
@ 7 days | @ 6 days
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
DROP TABLE tswtz_partitioned_table;
|
|
@ -17,17 +17,18 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 8 days ago | @ 9 days ago
|
|
||||||
@ 9 days ago | @ 10 days ago
|
|
||||||
@ 10 days ago | @ 11 days ago
|
|
||||||
@ 11 days ago | @ 12 days ago
|
|
||||||
@ 12 days ago | @ 13 days ago
|
|
||||||
@ 13 days ago | @ 14 days ago
|
|
||||||
@ 14 days ago | @ 15 days ago
|
|
||||||
@ 15 days ago | @ 16 days ago
|
@ 15 days ago | @ 16 days ago
|
||||||
|
@ 14 days ago | @ 15 days ago
|
||||||
|
@ 13 days ago | @ 14 days ago
|
||||||
|
@ 12 days ago | @ 13 days ago
|
||||||
|
@ 11 days ago | @ 12 days ago
|
||||||
|
@ 10 days ago | @ 11 days ago
|
||||||
|
@ 9 days ago | @ 10 days ago
|
||||||
|
@ 8 days ago | @ 9 days ago
|
||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -41,25 +42,26 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days', now() - INTERVAL '15 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days', now() - INTERVAL '15 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 15 days | @ 14 days
|
|
||||||
@ 14 days | @ 13 days
|
|
||||||
@ 13 days | @ 12 days
|
|
||||||
@ 12 days | @ 11 days
|
|
||||||
@ 11 days | @ 10 days
|
|
||||||
@ 10 days | @ 9 days
|
|
||||||
@ 9 days | @ 8 days
|
|
||||||
@ 8 days | @ 7 days
|
|
||||||
@ 8 days ago | @ 9 days ago
|
|
||||||
@ 9 days ago | @ 10 days ago
|
|
||||||
@ 10 days ago | @ 11 days ago
|
|
||||||
@ 11 days ago | @ 12 days ago
|
|
||||||
@ 12 days ago | @ 13 days ago
|
|
||||||
@ 13 days ago | @ 14 days ago
|
|
||||||
@ 14 days ago | @ 15 days ago
|
|
||||||
@ 15 days ago | @ 16 days ago
|
@ 15 days ago | @ 16 days ago
|
||||||
|
@ 14 days ago | @ 15 days ago
|
||||||
|
@ 13 days ago | @ 14 days ago
|
||||||
|
@ 12 days ago | @ 13 days ago
|
||||||
|
@ 11 days ago | @ 12 days ago
|
||||||
|
@ 10 days ago | @ 11 days ago
|
||||||
|
@ 9 days ago | @ 10 days ago
|
||||||
|
@ 8 days ago | @ 9 days ago
|
||||||
|
@ 8 days | @ 7 days
|
||||||
|
@ 9 days | @ 8 days
|
||||||
|
@ 10 days | @ 9 days
|
||||||
|
@ 11 days | @ 10 days
|
||||||
|
@ 12 days | @ 11 days
|
||||||
|
@ 13 days | @ 12 days
|
||||||
|
@ 14 days | @ 13 days
|
||||||
|
@ 15 days | @ 14 days
|
||||||
(16 rows)
|
(16 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -73,13 +75,14 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '45 days', now() - INTERVAL '45 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '45 days', now() - INTERVAL '45 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 45 days | @ 40 days
|
|
||||||
@ 40 days | @ 35 days
|
|
||||||
@ 40 days ago | @ 45 days ago
|
|
||||||
@ 45 days ago | @ 50 days ago
|
@ 45 days ago | @ 50 days ago
|
||||||
|
@ 40 days ago | @ 45 days ago
|
||||||
|
@ 40 days | @ 35 days
|
||||||
|
@ 45 days | @ 40 days
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -93,13 +96,14 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('week', now()) - range_from_value::date as from_diff,
|
date_trunc('week', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('week', now()) - range_to_value::date as to_diff
|
date_trunc('week', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '65 days', now() - INTERVAL '65 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '65 days', now() - INTERVAL '65 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 63 days | @ 56 days
|
|
||||||
@ 56 days | @ 49 days
|
|
||||||
@ 56 days ago | @ 63 days ago
|
|
||||||
@ 63 days ago | @ 70 days ago
|
@ 63 days ago | @ 70 days ago
|
||||||
|
@ 56 days ago | @ 63 days ago
|
||||||
|
@ 56 days | @ 49 days
|
||||||
|
@ 63 days | @ 56 days
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -113,7 +117,8 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -135,26 +140,27 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 8 hours ago | @ 9 hours ago
|
|
||||||
@ 9 hours ago | @ 10 hours ago
|
|
||||||
@ 10 hours ago | @ 11 hours ago
|
|
||||||
@ 11 hours ago | @ 12 hours ago
|
|
||||||
@ 12 hours ago | @ 13 hours ago
|
|
||||||
@ 13 hours ago | @ 14 hours ago
|
|
||||||
@ 14 hours ago | @ 15 hours ago
|
|
||||||
@ 15 hours ago | @ 16 hours ago
|
|
||||||
@ 16 hours ago | @ 17 hours ago
|
|
||||||
@ 17 hours ago | @ 18 hours ago
|
|
||||||
@ 18 hours ago | @ 19 hours ago
|
|
||||||
@ 19 hours ago | @ 20 hours ago
|
|
||||||
@ 20 hours ago | @ 21 hours ago
|
|
||||||
@ 21 hours ago | @ 22 hours ago
|
|
||||||
@ 22 hours ago | @ 23 hours ago
|
|
||||||
@ 23 hours ago | @ 1 day ago
|
|
||||||
@ 1 day ago | @ 1 day 1 hour ago
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
(17 rows)
|
(17 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -168,43 +174,44 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 1 day | @ 23 hours
|
|
||||||
@ 23 hours | @ 22 hours
|
|
||||||
@ 22 hours | @ 21 hours
|
|
||||||
@ 21 hours | @ 20 hours
|
|
||||||
@ 20 hours | @ 19 hours
|
|
||||||
@ 19 hours | @ 18 hours
|
|
||||||
@ 18 hours | @ 17 hours
|
|
||||||
@ 17 hours | @ 16 hours
|
|
||||||
@ 16 hours | @ 15 hours
|
|
||||||
@ 15 hours | @ 14 hours
|
|
||||||
@ 14 hours | @ 13 hours
|
|
||||||
@ 13 hours | @ 12 hours
|
|
||||||
@ 12 hours | @ 11 hours
|
|
||||||
@ 11 hours | @ 10 hours
|
|
||||||
@ 10 hours | @ 9 hours
|
|
||||||
@ 9 hours | @ 8 hours
|
|
||||||
@ 8 hours | @ 7 hours
|
|
||||||
@ 8 hours ago | @ 9 hours ago
|
|
||||||
@ 9 hours ago | @ 10 hours ago
|
|
||||||
@ 10 hours ago | @ 11 hours ago
|
|
||||||
@ 11 hours ago | @ 12 hours ago
|
|
||||||
@ 12 hours ago | @ 13 hours ago
|
|
||||||
@ 13 hours ago | @ 14 hours ago
|
|
||||||
@ 14 hours ago | @ 15 hours ago
|
|
||||||
@ 15 hours ago | @ 16 hours ago
|
|
||||||
@ 16 hours ago | @ 17 hours ago
|
|
||||||
@ 17 hours ago | @ 18 hours ago
|
|
||||||
@ 18 hours ago | @ 19 hours ago
|
|
||||||
@ 19 hours ago | @ 20 hours ago
|
|
||||||
@ 20 hours ago | @ 21 hours ago
|
|
||||||
@ 21 hours ago | @ 22 hours ago
|
|
||||||
@ 22 hours ago | @ 23 hours ago
|
|
||||||
@ 23 hours ago | @ 1 day ago
|
|
||||||
@ 1 day ago | @ 1 day 1 hour ago
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
|
@ 8 hours | @ 7 hours
|
||||||
|
@ 9 hours | @ 8 hours
|
||||||
|
@ 10 hours | @ 9 hours
|
||||||
|
@ 11 hours | @ 10 hours
|
||||||
|
@ 12 hours | @ 11 hours
|
||||||
|
@ 13 hours | @ 12 hours
|
||||||
|
@ 14 hours | @ 13 hours
|
||||||
|
@ 15 hours | @ 14 hours
|
||||||
|
@ 16 hours | @ 15 hours
|
||||||
|
@ 17 hours | @ 16 hours
|
||||||
|
@ 18 hours | @ 17 hours
|
||||||
|
@ 19 hours | @ 18 hours
|
||||||
|
@ 20 hours | @ 19 hours
|
||||||
|
@ 21 hours | @ 20 hours
|
||||||
|
@ 22 hours | @ 21 hours
|
||||||
|
@ 23 hours | @ 22 hours
|
||||||
|
@ 1 day | @ 23 hours
|
||||||
(34 rows)
|
(34 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -218,7 +225,8 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '6 hours');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -234,7 +242,8 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -256,26 +265,27 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 8 hours ago | @ 9 hours ago
|
|
||||||
@ 9 hours ago | @ 10 hours ago
|
|
||||||
@ 10 hours ago | @ 11 hours ago
|
|
||||||
@ 11 hours ago | @ 12 hours ago
|
|
||||||
@ 12 hours ago | @ 13 hours ago
|
|
||||||
@ 13 hours ago | @ 14 hours ago
|
|
||||||
@ 14 hours ago | @ 15 hours ago
|
|
||||||
@ 15 hours ago | @ 16 hours ago
|
|
||||||
@ 16 hours ago | @ 17 hours ago
|
|
||||||
@ 17 hours ago | @ 18 hours ago
|
|
||||||
@ 18 hours ago | @ 19 hours ago
|
|
||||||
@ 19 hours ago | @ 20 hours ago
|
|
||||||
@ 20 hours ago | @ 21 hours ago
|
|
||||||
@ 21 hours ago | @ 22 hours ago
|
|
||||||
@ 22 hours ago | @ 23 hours ago
|
|
||||||
@ 23 hours ago | @ 1 day ago
|
|
||||||
@ 1 day ago | @ 1 day 1 hour ago
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
(17 rows)
|
(17 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -289,43 +299,44 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
@ 1 day | @ 23 hours
|
|
||||||
@ 23 hours | @ 22 hours
|
|
||||||
@ 22 hours | @ 21 hours
|
|
||||||
@ 21 hours | @ 20 hours
|
|
||||||
@ 20 hours | @ 19 hours
|
|
||||||
@ 19 hours | @ 18 hours
|
|
||||||
@ 18 hours | @ 17 hours
|
|
||||||
@ 17 hours | @ 16 hours
|
|
||||||
@ 16 hours | @ 15 hours
|
|
||||||
@ 15 hours | @ 14 hours
|
|
||||||
@ 14 hours | @ 13 hours
|
|
||||||
@ 13 hours | @ 12 hours
|
|
||||||
@ 12 hours | @ 11 hours
|
|
||||||
@ 11 hours | @ 10 hours
|
|
||||||
@ 10 hours | @ 9 hours
|
|
||||||
@ 9 hours | @ 8 hours
|
|
||||||
@ 8 hours | @ 7 hours
|
|
||||||
@ 8 hours ago | @ 9 hours ago
|
|
||||||
@ 9 hours ago | @ 10 hours ago
|
|
||||||
@ 10 hours ago | @ 11 hours ago
|
|
||||||
@ 11 hours ago | @ 12 hours ago
|
|
||||||
@ 12 hours ago | @ 13 hours ago
|
|
||||||
@ 13 hours ago | @ 14 hours ago
|
|
||||||
@ 14 hours ago | @ 15 hours ago
|
|
||||||
@ 15 hours ago | @ 16 hours ago
|
|
||||||
@ 16 hours ago | @ 17 hours ago
|
|
||||||
@ 17 hours ago | @ 18 hours ago
|
|
||||||
@ 18 hours ago | @ 19 hours ago
|
|
||||||
@ 19 hours ago | @ 20 hours ago
|
|
||||||
@ 20 hours ago | @ 21 hours ago
|
|
||||||
@ 21 hours ago | @ 22 hours ago
|
|
||||||
@ 22 hours ago | @ 23 hours ago
|
|
||||||
@ 23 hours ago | @ 1 day ago
|
|
||||||
@ 1 day ago | @ 1 day 1 hour ago
|
@ 1 day ago | @ 1 day 1 hour ago
|
||||||
|
@ 23 hours ago | @ 1 day ago
|
||||||
|
@ 22 hours ago | @ 23 hours ago
|
||||||
|
@ 21 hours ago | @ 22 hours ago
|
||||||
|
@ 20 hours ago | @ 21 hours ago
|
||||||
|
@ 19 hours ago | @ 20 hours ago
|
||||||
|
@ 18 hours ago | @ 19 hours ago
|
||||||
|
@ 17 hours ago | @ 18 hours ago
|
||||||
|
@ 16 hours ago | @ 17 hours ago
|
||||||
|
@ 15 hours ago | @ 16 hours ago
|
||||||
|
@ 14 hours ago | @ 15 hours ago
|
||||||
|
@ 13 hours ago | @ 14 hours ago
|
||||||
|
@ 12 hours ago | @ 13 hours ago
|
||||||
|
@ 11 hours ago | @ 12 hours ago
|
||||||
|
@ 10 hours ago | @ 11 hours ago
|
||||||
|
@ 9 hours ago | @ 10 hours ago
|
||||||
|
@ 8 hours ago | @ 9 hours ago
|
||||||
|
@ 8 hours | @ 7 hours
|
||||||
|
@ 9 hours | @ 8 hours
|
||||||
|
@ 10 hours | @ 9 hours
|
||||||
|
@ 11 hours | @ 10 hours
|
||||||
|
@ 12 hours | @ 11 hours
|
||||||
|
@ 13 hours | @ 12 hours
|
||||||
|
@ 14 hours | @ 13 hours
|
||||||
|
@ 15 hours | @ 14 hours
|
||||||
|
@ 16 hours | @ 15 hours
|
||||||
|
@ 17 hours | @ 16 hours
|
||||||
|
@ 18 hours | @ 17 hours
|
||||||
|
@ 19 hours | @ 18 hours
|
||||||
|
@ 20 hours | @ 19 hours
|
||||||
|
@ 21 hours | @ 20 hours
|
||||||
|
@ 22 hours | @ 21 hours
|
||||||
|
@ 23 hours | @ 22 hours
|
||||||
|
@ 1 day | @ 23 hours
|
||||||
(34 rows)
|
(34 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
@ -339,7 +350,8 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -355,7 +367,8 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('day', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('day', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
from_diff | to_diff
|
from_diff | to_diff
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
|
@ -0,0 +1,168 @@
|
||||||
|
-- Show get_missing_partition_ranges function can be only callede for timeseries tables
|
||||||
|
CREATE TABLE date_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdate date,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdate);
|
||||||
|
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15 days');
|
||||||
|
|
||||||
|
-- Create missing partitions for various ranges on date partitioned table
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '15 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '10 days', now() + INTERVAL '10 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days');
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '45 days', now() + INTERVAL '45 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week');
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '65 days', now() + INTERVAL '65 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
|
SELECT create_missing_partitions('date_partitioned_table', now() + INTERVAL '5 days', now() + INTERVAL '5 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::date as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::date as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'date_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
DROP TABLE date_partitioned_table;
|
||||||
|
|
||||||
|
-- Create missing partitions for various ranges on timestamptz partitioned table
|
||||||
|
CREATE TABLE tstz_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdatetime timestamp with time zone,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day');
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '6 hours');
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
|
||||||
|
SELECT create_missing_partitions('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::timestamp with time zone as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::timestamp with time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tstz_partitioned_table'::regclass;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
DROP TABLE tstz_partitioned_table;
|
||||||
|
|
||||||
|
-- Show range values for timestamp without time zone partitioned table
|
||||||
|
CREATE TABLE tswtz_partitioned_table(
|
||||||
|
measureid integer,
|
||||||
|
eventdatetime timestamp without time zone,
|
||||||
|
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day');
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours');
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
||||||
|
SELECT
|
||||||
|
date_trunc('hour', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('hour', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day');
|
||||||
|
SELECT create_missing_partitions('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
||||||
|
SELECT
|
||||||
|
date_trunc('day', now()) - from_value::timestamp without time zone as from_diff,
|
||||||
|
date_trunc('day', now()) - to_value::timestamp without time zone as to_diff
|
||||||
|
FROM pg_catalog.time_partitions
|
||||||
|
WHERE parent_table = 'tswtz_partitioned_table'::regclass
|
||||||
|
ORDER BY 1,2;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
DROP TABLE tswtz_partitioned_table;
|
|
@ -12,7 +12,8 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -20,7 +21,8 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days', now() - INTERVAL '15 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '15 days', now() - INTERVAL '15 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -28,7 +30,8 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '5 days');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '45 days', now() - INTERVAL '45 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '45 days', now() - INTERVAL '45 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -36,7 +39,8 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 week');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('week', now()) - range_from_value::date as from_diff,
|
date_trunc('week', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('week', now()) - range_to_value::date as to_diff
|
date_trunc('week', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '65 days', now() - INTERVAL '65 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '65 days', now() - INTERVAL '65 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -44,7 +48,8 @@ SELECT create_timeseries_table('date_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::date as from_diff,
|
date_trunc('day', now()) - range_from_value::date as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::date as to_diff
|
date_trunc('day', now()) - range_to_value::date as to_diff
|
||||||
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
FROM get_missing_partition_ranges('date_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
DROP TABLE date_partitioned_table;
|
DROP TABLE date_partitioned_table;
|
||||||
|
@ -54,12 +59,14 @@ CREATE TABLE tstz_partitioned_table(
|
||||||
measureid integer,
|
measureid integer,
|
||||||
eventdatetime timestamp with time zone,
|
eventdatetime timestamp with time zone,
|
||||||
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -67,7 +74,8 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -75,7 +83,8 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '6 hours');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -83,7 +92,8 @@ SELECT create_timeseries_table('tstz_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
date_trunc('day', now()) - range_from_value::timestamp with time zone as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
date_trunc('day', now()) - range_to_value::timestamp with time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
FROM get_missing_partition_ranges('tstz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
DROP TABLE tstz_partitioned_table;
|
DROP TABLE tstz_partitioned_table;
|
||||||
|
@ -93,12 +103,14 @@ CREATE TABLE tswtz_partitioned_table(
|
||||||
measureid integer,
|
measureid integer,
|
||||||
eventdatetime timestamp without time zone,
|
eventdatetime timestamp without time zone,
|
||||||
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
measure_data integer) PARTITION BY RANGE(eventdatetime);
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -106,7 +118,8 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 hour');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -114,7 +127,8 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '6 hours');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('hour', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('hour', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '1 day', now() - INTERVAL '1 day')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -122,7 +136,8 @@ SELECT create_timeseries_table('tswtz_partitioned_table', INTERVAL '1 day');
|
||||||
SELECT
|
SELECT
|
||||||
date_trunc('day', now()) - range_from_value::timestamp without time zone as from_diff,
|
date_trunc('day', now()) - range_from_value::timestamp without time zone as from_diff,
|
||||||
date_trunc('day', now()) - range_to_value::timestamp without time zone as to_diff
|
date_trunc('day', now()) - range_to_value::timestamp without time zone as to_diff
|
||||||
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days');
|
FROM get_missing_partition_ranges('tswtz_partitioned_table', now() + INTERVAL '5 days', now() - INTERVAL '5 days')
|
||||||
|
ORDER BY 1,2;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
DROP TABLE tswtz_partitioned_table;
|
DROP TABLE tswtz_partitioned_table;
|
||||||
|
|
|
@ -4,3 +4,4 @@ test: multi_test_catalog_views
|
||||||
|
|
||||||
test: timeseries_create_drop_timeseries_table
|
test: timeseries_create_drop_timeseries_table
|
||||||
test: timeseries_get_missing_partition_ranges
|
test: timeseries_get_missing_partition_ranges
|
||||||
|
test: timeseries_create_missing_partitions
|
Loading…
Reference in New Issue