mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-28 09:46:44 +08:00
This fixes the show_indexes test support function to properly show the columns of the indexes instead of the table. The function now also shows the expressions of expression indexes.
731 lines
63 KiB
Plaintext
731 lines
63 KiB
Plaintext
\ir include/insert_two_partitions.sql
|
|
\c single
|
|
CREATE TABLE PUBLIC."two_Partitions" (
|
|
"timeCustom" BIGINT NOT NULL,
|
|
device_id TEXT NOT NULL,
|
|
series_0 DOUBLE PRECISION NULL,
|
|
series_1 DOUBLE PRECISION NULL,
|
|
series_2 DOUBLE PRECISION NULL,
|
|
series_bool BOOLEAN NULL
|
|
);
|
|
CREATE INDEX ON PUBLIC."two_Partitions" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
|
CREATE INDEX ON PUBLIC."two_Partitions" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
|
CREATE INDEX ON PUBLIC."two_Partitions" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
|
CREATE INDEX ON PUBLIC."two_Partitions" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
|
CREATE INDEX ON PUBLIC."two_Partitions" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
|
CREATE INDEX ON PUBLIC."two_Partitions" ("timeCustom" DESC NULLS LAST, device_id);
|
|
SELECT * FROM create_hypertable('"public"."two_Partitions"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
\set QUIET off
|
|
BEGIN;
|
|
BEGIN
|
|
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
|
COPY 7
|
|
COMMIT;
|
|
COMMIT
|
|
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
|
(1257987600000000000, 'dev1', 1.5, 1),
|
|
(1257987600000000000, 'dev1', 1.5, 2),
|
|
(1257894000000000000, 'dev2', 1.5, 1),
|
|
(1257894002000000000, 'dev1', 2.5, 3);
|
|
INSERT 0 4
|
|
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
|
(1257894000000000000, 'dev2', 1.5, 2);
|
|
INSERT 0 1
|
|
\set QUIET on
|
|
SELECT * FROM test.show_columnsp('_timescaledb_internal.%');
|
|
Relation | Kind | Column | Column type | Nullable
|
|
------------------------------------------------------------------------------------+------+-------------+------------------+----------
|
|
_timescaledb_internal._hyper_1_1_chunk | r | timeCustom | bigint | t
|
|
_timescaledb_internal._hyper_1_1_chunk | r | device_id | text | t
|
|
_timescaledb_internal._hyper_1_1_chunk | r | series_0 | double precision | f
|
|
_timescaledb_internal._hyper_1_1_chunk | r | series_1 | double precision | f
|
|
_timescaledb_internal._hyper_1_1_chunk | r | series_2 | double precision | f
|
|
_timescaledb_internal._hyper_1_1_chunk | r | series_bool | boolean | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_device_id_timeCustom_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_device_id_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_device_id_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_device_id_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_0_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_0_idx" | i | series_0 | double precision | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_1_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_1_idx" | i | series_1 | double precision | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_2_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_2_idx" | i | series_2 | double precision | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_bool_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_bool_idx" | i | series_bool | boolean | f
|
|
_timescaledb_internal._hyper_1_2_chunk | r | timeCustom | bigint | t
|
|
_timescaledb_internal._hyper_1_2_chunk | r | device_id | text | t
|
|
_timescaledb_internal._hyper_1_2_chunk | r | series_0 | double precision | f
|
|
_timescaledb_internal._hyper_1_2_chunk | r | series_1 | double precision | f
|
|
_timescaledb_internal._hyper_1_2_chunk | r | series_2 | double precision | f
|
|
_timescaledb_internal._hyper_1_2_chunk | r | series_bool | boolean | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_device_id_timeCustom_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_device_id_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_device_id_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_device_id_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_0_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_0_idx" | i | series_0 | double precision | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_1_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_1_idx" | i | series_1 | double precision | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_2_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_2_idx" | i | series_2 | double precision | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_bool_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_bool_idx" | i | series_bool | boolean | f
|
|
_timescaledb_internal._hyper_1_3_chunk | r | timeCustom | bigint | t
|
|
_timescaledb_internal._hyper_1_3_chunk | r | device_id | text | t
|
|
_timescaledb_internal._hyper_1_3_chunk | r | series_0 | double precision | f
|
|
_timescaledb_internal._hyper_1_3_chunk | r | series_1 | double precision | f
|
|
_timescaledb_internal._hyper_1_3_chunk | r | series_2 | double precision | f
|
|
_timescaledb_internal._hyper_1_3_chunk | r | series_bool | boolean | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_device_id_timeCustom_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_device_id_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_device_id_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_device_id_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_0_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_0_idx" | i | series_0 | double precision | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_1_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_1_idx" | i | series_1 | double precision | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_2_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_2_idx" | i | series_2 | double precision | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_bool_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_bool_idx" | i | series_bool | boolean | f
|
|
_timescaledb_internal._hyper_1_4_chunk | r | timeCustom | bigint | t
|
|
_timescaledb_internal._hyper_1_4_chunk | r | device_id | text | t
|
|
_timescaledb_internal._hyper_1_4_chunk | r | series_0 | double precision | f
|
|
_timescaledb_internal._hyper_1_4_chunk | r | series_1 | double precision | f
|
|
_timescaledb_internal._hyper_1_4_chunk | r | series_2 | double precision | f
|
|
_timescaledb_internal._hyper_1_4_chunk | r | series_bool | boolean | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_device_id_timeCustom_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_device_id_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_device_id_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_device_id_idx" | i | device_id | text | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_0_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_0_idx" | i | series_0 | double precision | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_1_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_1_idx" | i | series_1 | double precision | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_2_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_2_idx" | i | series_2 | double precision | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_bool_idx" | i | timeCustom | bigint | f
|
|
_timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_bool_idx" | i | series_bool | boolean | f
|
|
(76 rows)
|
|
|
|
SELECT * FROM test.show_indexesp('_timescaledb_internal.%');
|
|
Table | Index | Columns | Expr | Unique | Primary | Exclusion | Tablespace
|
|
----------------------------------------+------------------------------------------------------------------------------------+--------------------------+------+--------+---------+-----------+------------
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_device_id_timeCustom_idx" | {device_id,timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_0_idx" | {timeCustom,series_0} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_1_idx" | {timeCustom,series_1} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_2_idx" | {timeCustom,series_2} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_series_bool_idx" | {timeCustom,series_bool} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_device_id_idx" | {timeCustom,device_id} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_1_chunk | _timescaledb_internal."_hyper_1_1_chunk_two_Partitions_timeCustom_idx" | {timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_device_id_timeCustom_idx" | {device_id,timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_0_idx" | {timeCustom,series_0} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_1_idx" | {timeCustom,series_1} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_2_idx" | {timeCustom,series_2} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_series_bool_idx" | {timeCustom,series_bool} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_device_id_idx" | {timeCustom,device_id} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_2_chunk | _timescaledb_internal."_hyper_1_2_chunk_two_Partitions_timeCustom_idx" | {timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_device_id_timeCustom_idx" | {device_id,timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_0_idx" | {timeCustom,series_0} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_1_idx" | {timeCustom,series_1} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_2_idx" | {timeCustom,series_2} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_series_bool_idx" | {timeCustom,series_bool} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_device_id_idx" | {timeCustom,device_id} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_3_chunk | _timescaledb_internal."_hyper_1_3_chunk_two_Partitions_timeCustom_idx" | {timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_device_id_timeCustom_idx" | {device_id,timeCustom} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_0_idx" | {timeCustom,series_0} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_1_idx" | {timeCustom,series_1} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_2_idx" | {timeCustom,series_2} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_series_bool_idx" | {timeCustom,series_bool} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_device_id_idx" | {timeCustom,device_id} | | f | f | f |
|
|
_timescaledb_internal._hyper_1_4_chunk | _timescaledb_internal."_hyper_1_4_chunk_two_Partitions_timeCustom_idx" | {timeCustom} | | f | f | f |
|
|
(28 rows)
|
|
|
|
SELECT * FROM _timescaledb_catalog.chunk;
|
|
id | hypertable_id | schema_name | table_name
|
|
----+---------------+-----------------------+------------------
|
|
1 | 1 | _timescaledb_internal | _hyper_1_1_chunk
|
|
2 | 1 | _timescaledb_internal | _hyper_1_2_chunk
|
|
3 | 1 | _timescaledb_internal | _hyper_1_3_chunk
|
|
4 | 1 | _timescaledb_internal | _hyper_1_4_chunk
|
|
(4 rows)
|
|
|
|
SELECT * FROM "two_Partitions" ORDER BY "timeCustom", device_id;
|
|
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
|
---------------------+-----------+----------+----------+----------+-------------
|
|
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
|
1257894000000000000 | dev1 | 1.5 | 2 | |
|
|
1257894000000000000 | dev2 | 1.5 | 2 | |
|
|
1257894000000000000 | dev2 | 1.5 | 1 | |
|
|
1257894000000001000 | dev1 | 2.5 | 3 | |
|
|
1257894001000000000 | dev1 | 3.5 | 4 | |
|
|
1257894002000000000 | dev1 | 2.5 | 3 | |
|
|
1257894002000000000 | dev1 | 5.5 | 6 | | t
|
|
1257894002000000000 | dev1 | 5.5 | 7 | | f
|
|
1257897600000000000 | dev1 | 4.5 | 5 | | f
|
|
1257987600000000000 | dev1 | 1.5 | 2 | |
|
|
1257987600000000000 | dev1 | 1.5 | 1 | |
|
|
(12 rows)
|
|
|
|
SELECT * FROM ONLY "two_Partitions";
|
|
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
|
------------+-----------+----------+----------+----------+-------------
|
|
(0 rows)
|
|
|
|
CREATE TABLE error_test(time timestamp, temp float8, device text NOT NULL);
|
|
SELECT create_hypertable('error_test', 'time', 'device', 2);
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
\set QUIET off
|
|
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:20.1 2017', 21.3, 'dev1');
|
|
INSERT 0 1
|
|
\set ON_ERROR_STOP 0
|
|
-- generate insert error
|
|
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:22.3 2017', 21.1, NULL);
|
|
ERROR: null value in column "device" violates not-null constraint
|
|
\set ON_ERROR_STOP 1
|
|
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:25.7 2017', 22.4, 'dev2');
|
|
INSERT 0 1
|
|
\set QUIET on
|
|
SELECT * FROM error_test;
|
|
time | temp | device
|
|
----------------------------+------+--------
|
|
Mon Mar 20 09:18:20.1 2017 | 21.3 | dev1
|
|
Mon Mar 20 09:18:25.7 2017 | 22.4 | dev2
|
|
(2 rows)
|
|
|
|
--test character(9) partition keys since there were issues with padding causing partitioning errors
|
|
CREATE TABLE tick_character (
|
|
symbol character(9) NOT NULL,
|
|
mid REAL NOT NULL,
|
|
spread REAL NOT NULL,
|
|
time TIMESTAMPTZ NOT NULL
|
|
);
|
|
SELECT create_hypertable ('tick_character', 'time', 'symbol', 2);
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
INSERT INTO tick_character ( symbol, mid, spread, time ) VALUES ( 'GBPJPY', 142.639000, 5.80, 'Mon Mar 20 09:18:22.3 2017') RETURNING time, symbol, mid;
|
|
time | symbol | mid
|
|
--------------------------------+-----------+---------
|
|
Mon Mar 20 09:18:22.3 2017 PDT | GBPJPY | 142.639
|
|
(1 row)
|
|
|
|
SELECT * FROM tick_character;
|
|
symbol | mid | spread | time
|
|
-----------+---------+--------+--------------------------------
|
|
GBPJPY | 142.639 | 5.8 | Mon Mar 20 09:18:22.3 2017 PDT
|
|
(1 row)
|
|
|
|
CREATE TABLE many_partitions_test(time timestamp, temp float8, device text NOT NULL);
|
|
SELECT create_hypertable('many_partitions_test', 'time', 'device', 1000);
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
--NOTE: how much slower the first two queries are -- they are creating chunks
|
|
INSERT INTO many_partitions_test
|
|
SELECT to_timestamp(ser), ser, ser::text FROM generate_series(1,100) ser;
|
|
INSERT INTO many_partitions_test
|
|
SELECT to_timestamp(ser), ser, ser::text FROM generate_series(101,200) ser;
|
|
INSERT INTO many_partitions_test
|
|
SELECT to_timestamp(ser), ser, (ser-201)::text FROM generate_series(201,300) ser;
|
|
SELECT * FROM many_partitions_test ORDER BY time DESC LIMIT 2;
|
|
time | temp | device
|
|
--------------------------+------+--------
|
|
Wed Dec 31 16:05:00 1969 | 300 | 99
|
|
Wed Dec 31 16:04:59 1969 | 299 | 98
|
|
(2 rows)
|
|
|
|
SELECT count(*) FROM many_partitions_test;
|
|
count
|
|
-------
|
|
300
|
|
(1 row)
|
|
|
|
CREATE TABLE date_col_test(time date, temp float8, device text NOT NULL);
|
|
SELECT create_hypertable('date_col_test', 'time', 'device', 1000, chunk_time_interval => INTERVAL '1 Day');
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
INSERT INTO date_col_test
|
|
VALUES ('2001-02-01', 98, 'dev1'),
|
|
('2001-03-02', 98, 'dev1');
|
|
SELECT * FROM date_col_test WHERE time > '2001-01-01';
|
|
time | temp | device
|
|
------------+------+--------
|
|
03-02-2001 | 98 | dev1
|
|
02-01-2001 | 98 | dev1
|
|
(2 rows)
|
|
|
|
CREATE TABLE many_partitions_test_1m (time timestamp, temp float8, device text NOT NULL);
|
|
SELECT create_hypertable('many_partitions_test_1m', 'time', 'device', 1000);
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
EXPLAIN (verbose on, costs off)
|
|
INSERT INTO many_partitions_test_1m(time, temp, device)
|
|
SELECT time_bucket('1 minute', time) AS period, avg(temp), device
|
|
FROM many_partitions_test
|
|
GROUP BY period, device;
|
|
QUERY PLAN
|
|
----------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Custom Scan (HypertableInsert)
|
|
-> Insert on public.many_partitions_test_1m
|
|
-> Custom Scan (ChunkDispatch)
|
|
Output: many_partitions_test_1m."time", many_partitions_test_1m.temp, many_partitions_test_1m.device
|
|
-> HashAggregate
|
|
Output: (time_bucket('@ 1 min'::interval, many_partitions_test."time")), avg(many_partitions_test.temp), many_partitions_test.device
|
|
Group Key: time_bucket('@ 1 min'::interval, many_partitions_test."time"), many_partitions_test.device
|
|
-> Result
|
|
Output: time_bucket('@ 1 min'::interval, many_partitions_test."time"), many_partitions_test.device, many_partitions_test.temp
|
|
-> Append
|
|
-> Seq Scan on public.many_partitions_test
|
|
Output: many_partitions_test."time", many_partitions_test.temp, many_partitions_test.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_9_chunk
|
|
Output: _hyper_4_9_chunk."time", _hyper_4_9_chunk.temp, _hyper_4_9_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_10_chunk
|
|
Output: _hyper_4_10_chunk."time", _hyper_4_10_chunk.temp, _hyper_4_10_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_11_chunk
|
|
Output: _hyper_4_11_chunk."time", _hyper_4_11_chunk.temp, _hyper_4_11_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_12_chunk
|
|
Output: _hyper_4_12_chunk."time", _hyper_4_12_chunk.temp, _hyper_4_12_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_13_chunk
|
|
Output: _hyper_4_13_chunk."time", _hyper_4_13_chunk.temp, _hyper_4_13_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_14_chunk
|
|
Output: _hyper_4_14_chunk."time", _hyper_4_14_chunk.temp, _hyper_4_14_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_15_chunk
|
|
Output: _hyper_4_15_chunk."time", _hyper_4_15_chunk.temp, _hyper_4_15_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_16_chunk
|
|
Output: _hyper_4_16_chunk."time", _hyper_4_16_chunk.temp, _hyper_4_16_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_17_chunk
|
|
Output: _hyper_4_17_chunk."time", _hyper_4_17_chunk.temp, _hyper_4_17_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_18_chunk
|
|
Output: _hyper_4_18_chunk."time", _hyper_4_18_chunk.temp, _hyper_4_18_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_19_chunk
|
|
Output: _hyper_4_19_chunk."time", _hyper_4_19_chunk.temp, _hyper_4_19_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_20_chunk
|
|
Output: _hyper_4_20_chunk."time", _hyper_4_20_chunk.temp, _hyper_4_20_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_21_chunk
|
|
Output: _hyper_4_21_chunk."time", _hyper_4_21_chunk.temp, _hyper_4_21_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_22_chunk
|
|
Output: _hyper_4_22_chunk."time", _hyper_4_22_chunk.temp, _hyper_4_22_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_23_chunk
|
|
Output: _hyper_4_23_chunk."time", _hyper_4_23_chunk.temp, _hyper_4_23_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_24_chunk
|
|
Output: _hyper_4_24_chunk."time", _hyper_4_24_chunk.temp, _hyper_4_24_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_25_chunk
|
|
Output: _hyper_4_25_chunk."time", _hyper_4_25_chunk.temp, _hyper_4_25_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_26_chunk
|
|
Output: _hyper_4_26_chunk."time", _hyper_4_26_chunk.temp, _hyper_4_26_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_27_chunk
|
|
Output: _hyper_4_27_chunk."time", _hyper_4_27_chunk.temp, _hyper_4_27_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_28_chunk
|
|
Output: _hyper_4_28_chunk."time", _hyper_4_28_chunk.temp, _hyper_4_28_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_29_chunk
|
|
Output: _hyper_4_29_chunk."time", _hyper_4_29_chunk.temp, _hyper_4_29_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_30_chunk
|
|
Output: _hyper_4_30_chunk."time", _hyper_4_30_chunk.temp, _hyper_4_30_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_31_chunk
|
|
Output: _hyper_4_31_chunk."time", _hyper_4_31_chunk.temp, _hyper_4_31_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_32_chunk
|
|
Output: _hyper_4_32_chunk."time", _hyper_4_32_chunk.temp, _hyper_4_32_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_33_chunk
|
|
Output: _hyper_4_33_chunk."time", _hyper_4_33_chunk.temp, _hyper_4_33_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_34_chunk
|
|
Output: _hyper_4_34_chunk."time", _hyper_4_34_chunk.temp, _hyper_4_34_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_35_chunk
|
|
Output: _hyper_4_35_chunk."time", _hyper_4_35_chunk.temp, _hyper_4_35_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_36_chunk
|
|
Output: _hyper_4_36_chunk."time", _hyper_4_36_chunk.temp, _hyper_4_36_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_37_chunk
|
|
Output: _hyper_4_37_chunk."time", _hyper_4_37_chunk.temp, _hyper_4_37_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_38_chunk
|
|
Output: _hyper_4_38_chunk."time", _hyper_4_38_chunk.temp, _hyper_4_38_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_39_chunk
|
|
Output: _hyper_4_39_chunk."time", _hyper_4_39_chunk.temp, _hyper_4_39_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_40_chunk
|
|
Output: _hyper_4_40_chunk."time", _hyper_4_40_chunk.temp, _hyper_4_40_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_41_chunk
|
|
Output: _hyper_4_41_chunk."time", _hyper_4_41_chunk.temp, _hyper_4_41_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_42_chunk
|
|
Output: _hyper_4_42_chunk."time", _hyper_4_42_chunk.temp, _hyper_4_42_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_43_chunk
|
|
Output: _hyper_4_43_chunk."time", _hyper_4_43_chunk.temp, _hyper_4_43_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_44_chunk
|
|
Output: _hyper_4_44_chunk."time", _hyper_4_44_chunk.temp, _hyper_4_44_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_45_chunk
|
|
Output: _hyper_4_45_chunk."time", _hyper_4_45_chunk.temp, _hyper_4_45_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_46_chunk
|
|
Output: _hyper_4_46_chunk."time", _hyper_4_46_chunk.temp, _hyper_4_46_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_47_chunk
|
|
Output: _hyper_4_47_chunk."time", _hyper_4_47_chunk.temp, _hyper_4_47_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_48_chunk
|
|
Output: _hyper_4_48_chunk."time", _hyper_4_48_chunk.temp, _hyper_4_48_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_49_chunk
|
|
Output: _hyper_4_49_chunk."time", _hyper_4_49_chunk.temp, _hyper_4_49_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_50_chunk
|
|
Output: _hyper_4_50_chunk."time", _hyper_4_50_chunk.temp, _hyper_4_50_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_51_chunk
|
|
Output: _hyper_4_51_chunk."time", _hyper_4_51_chunk.temp, _hyper_4_51_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_52_chunk
|
|
Output: _hyper_4_52_chunk."time", _hyper_4_52_chunk.temp, _hyper_4_52_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_53_chunk
|
|
Output: _hyper_4_53_chunk."time", _hyper_4_53_chunk.temp, _hyper_4_53_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_54_chunk
|
|
Output: _hyper_4_54_chunk."time", _hyper_4_54_chunk.temp, _hyper_4_54_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_55_chunk
|
|
Output: _hyper_4_55_chunk."time", _hyper_4_55_chunk.temp, _hyper_4_55_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_56_chunk
|
|
Output: _hyper_4_56_chunk."time", _hyper_4_56_chunk.temp, _hyper_4_56_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_57_chunk
|
|
Output: _hyper_4_57_chunk."time", _hyper_4_57_chunk.temp, _hyper_4_57_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_58_chunk
|
|
Output: _hyper_4_58_chunk."time", _hyper_4_58_chunk.temp, _hyper_4_58_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_59_chunk
|
|
Output: _hyper_4_59_chunk."time", _hyper_4_59_chunk.temp, _hyper_4_59_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_60_chunk
|
|
Output: _hyper_4_60_chunk."time", _hyper_4_60_chunk.temp, _hyper_4_60_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_61_chunk
|
|
Output: _hyper_4_61_chunk."time", _hyper_4_61_chunk.temp, _hyper_4_61_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_62_chunk
|
|
Output: _hyper_4_62_chunk."time", _hyper_4_62_chunk.temp, _hyper_4_62_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_63_chunk
|
|
Output: _hyper_4_63_chunk."time", _hyper_4_63_chunk.temp, _hyper_4_63_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_64_chunk
|
|
Output: _hyper_4_64_chunk."time", _hyper_4_64_chunk.temp, _hyper_4_64_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_65_chunk
|
|
Output: _hyper_4_65_chunk."time", _hyper_4_65_chunk.temp, _hyper_4_65_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_66_chunk
|
|
Output: _hyper_4_66_chunk."time", _hyper_4_66_chunk.temp, _hyper_4_66_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_67_chunk
|
|
Output: _hyper_4_67_chunk."time", _hyper_4_67_chunk.temp, _hyper_4_67_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_68_chunk
|
|
Output: _hyper_4_68_chunk."time", _hyper_4_68_chunk.temp, _hyper_4_68_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_69_chunk
|
|
Output: _hyper_4_69_chunk."time", _hyper_4_69_chunk.temp, _hyper_4_69_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_70_chunk
|
|
Output: _hyper_4_70_chunk."time", _hyper_4_70_chunk.temp, _hyper_4_70_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_71_chunk
|
|
Output: _hyper_4_71_chunk."time", _hyper_4_71_chunk.temp, _hyper_4_71_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_72_chunk
|
|
Output: _hyper_4_72_chunk."time", _hyper_4_72_chunk.temp, _hyper_4_72_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_73_chunk
|
|
Output: _hyper_4_73_chunk."time", _hyper_4_73_chunk.temp, _hyper_4_73_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_74_chunk
|
|
Output: _hyper_4_74_chunk."time", _hyper_4_74_chunk.temp, _hyper_4_74_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_75_chunk
|
|
Output: _hyper_4_75_chunk."time", _hyper_4_75_chunk.temp, _hyper_4_75_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_76_chunk
|
|
Output: _hyper_4_76_chunk."time", _hyper_4_76_chunk.temp, _hyper_4_76_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_77_chunk
|
|
Output: _hyper_4_77_chunk."time", _hyper_4_77_chunk.temp, _hyper_4_77_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_78_chunk
|
|
Output: _hyper_4_78_chunk."time", _hyper_4_78_chunk.temp, _hyper_4_78_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_79_chunk
|
|
Output: _hyper_4_79_chunk."time", _hyper_4_79_chunk.temp, _hyper_4_79_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_80_chunk
|
|
Output: _hyper_4_80_chunk."time", _hyper_4_80_chunk.temp, _hyper_4_80_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_81_chunk
|
|
Output: _hyper_4_81_chunk."time", _hyper_4_81_chunk.temp, _hyper_4_81_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_82_chunk
|
|
Output: _hyper_4_82_chunk."time", _hyper_4_82_chunk.temp, _hyper_4_82_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_83_chunk
|
|
Output: _hyper_4_83_chunk."time", _hyper_4_83_chunk.temp, _hyper_4_83_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_84_chunk
|
|
Output: _hyper_4_84_chunk."time", _hyper_4_84_chunk.temp, _hyper_4_84_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_85_chunk
|
|
Output: _hyper_4_85_chunk."time", _hyper_4_85_chunk.temp, _hyper_4_85_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_86_chunk
|
|
Output: _hyper_4_86_chunk."time", _hyper_4_86_chunk.temp, _hyper_4_86_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_87_chunk
|
|
Output: _hyper_4_87_chunk."time", _hyper_4_87_chunk.temp, _hyper_4_87_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_88_chunk
|
|
Output: _hyper_4_88_chunk."time", _hyper_4_88_chunk.temp, _hyper_4_88_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_89_chunk
|
|
Output: _hyper_4_89_chunk."time", _hyper_4_89_chunk.temp, _hyper_4_89_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_90_chunk
|
|
Output: _hyper_4_90_chunk."time", _hyper_4_90_chunk.temp, _hyper_4_90_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_91_chunk
|
|
Output: _hyper_4_91_chunk."time", _hyper_4_91_chunk.temp, _hyper_4_91_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_92_chunk
|
|
Output: _hyper_4_92_chunk."time", _hyper_4_92_chunk.temp, _hyper_4_92_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_93_chunk
|
|
Output: _hyper_4_93_chunk."time", _hyper_4_93_chunk.temp, _hyper_4_93_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_94_chunk
|
|
Output: _hyper_4_94_chunk."time", _hyper_4_94_chunk.temp, _hyper_4_94_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_95_chunk
|
|
Output: _hyper_4_95_chunk."time", _hyper_4_95_chunk.temp, _hyper_4_95_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_96_chunk
|
|
Output: _hyper_4_96_chunk."time", _hyper_4_96_chunk.temp, _hyper_4_96_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_97_chunk
|
|
Output: _hyper_4_97_chunk."time", _hyper_4_97_chunk.temp, _hyper_4_97_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_98_chunk
|
|
Output: _hyper_4_98_chunk."time", _hyper_4_98_chunk.temp, _hyper_4_98_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_99_chunk
|
|
Output: _hyper_4_99_chunk."time", _hyper_4_99_chunk.temp, _hyper_4_99_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_100_chunk
|
|
Output: _hyper_4_100_chunk."time", _hyper_4_100_chunk.temp, _hyper_4_100_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_101_chunk
|
|
Output: _hyper_4_101_chunk."time", _hyper_4_101_chunk.temp, _hyper_4_101_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_102_chunk
|
|
Output: _hyper_4_102_chunk."time", _hyper_4_102_chunk.temp, _hyper_4_102_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_103_chunk
|
|
Output: _hyper_4_103_chunk."time", _hyper_4_103_chunk.temp, _hyper_4_103_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_104_chunk
|
|
Output: _hyper_4_104_chunk."time", _hyper_4_104_chunk.temp, _hyper_4_104_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_105_chunk
|
|
Output: _hyper_4_105_chunk."time", _hyper_4_105_chunk.temp, _hyper_4_105_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_106_chunk
|
|
Output: _hyper_4_106_chunk."time", _hyper_4_106_chunk.temp, _hyper_4_106_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_107_chunk
|
|
Output: _hyper_4_107_chunk."time", _hyper_4_107_chunk.temp, _hyper_4_107_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_108_chunk
|
|
Output: _hyper_4_108_chunk."time", _hyper_4_108_chunk.temp, _hyper_4_108_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_109_chunk
|
|
Output: _hyper_4_109_chunk."time", _hyper_4_109_chunk.temp, _hyper_4_109_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_110_chunk
|
|
Output: _hyper_4_110_chunk."time", _hyper_4_110_chunk.temp, _hyper_4_110_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_111_chunk
|
|
Output: _hyper_4_111_chunk."time", _hyper_4_111_chunk.temp, _hyper_4_111_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_112_chunk
|
|
Output: _hyper_4_112_chunk."time", _hyper_4_112_chunk.temp, _hyper_4_112_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_113_chunk
|
|
Output: _hyper_4_113_chunk."time", _hyper_4_113_chunk.temp, _hyper_4_113_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_114_chunk
|
|
Output: _hyper_4_114_chunk."time", _hyper_4_114_chunk.temp, _hyper_4_114_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_115_chunk
|
|
Output: _hyper_4_115_chunk."time", _hyper_4_115_chunk.temp, _hyper_4_115_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_116_chunk
|
|
Output: _hyper_4_116_chunk."time", _hyper_4_116_chunk.temp, _hyper_4_116_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_117_chunk
|
|
Output: _hyper_4_117_chunk."time", _hyper_4_117_chunk.temp, _hyper_4_117_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_118_chunk
|
|
Output: _hyper_4_118_chunk."time", _hyper_4_118_chunk.temp, _hyper_4_118_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_119_chunk
|
|
Output: _hyper_4_119_chunk."time", _hyper_4_119_chunk.temp, _hyper_4_119_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_120_chunk
|
|
Output: _hyper_4_120_chunk."time", _hyper_4_120_chunk.temp, _hyper_4_120_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_121_chunk
|
|
Output: _hyper_4_121_chunk."time", _hyper_4_121_chunk.temp, _hyper_4_121_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_122_chunk
|
|
Output: _hyper_4_122_chunk."time", _hyper_4_122_chunk.temp, _hyper_4_122_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_123_chunk
|
|
Output: _hyper_4_123_chunk."time", _hyper_4_123_chunk.temp, _hyper_4_123_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_124_chunk
|
|
Output: _hyper_4_124_chunk."time", _hyper_4_124_chunk.temp, _hyper_4_124_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_125_chunk
|
|
Output: _hyper_4_125_chunk."time", _hyper_4_125_chunk.temp, _hyper_4_125_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_126_chunk
|
|
Output: _hyper_4_126_chunk."time", _hyper_4_126_chunk.temp, _hyper_4_126_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_127_chunk
|
|
Output: _hyper_4_127_chunk."time", _hyper_4_127_chunk.temp, _hyper_4_127_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_128_chunk
|
|
Output: _hyper_4_128_chunk."time", _hyper_4_128_chunk.temp, _hyper_4_128_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_129_chunk
|
|
Output: _hyper_4_129_chunk."time", _hyper_4_129_chunk.temp, _hyper_4_129_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_130_chunk
|
|
Output: _hyper_4_130_chunk."time", _hyper_4_130_chunk.temp, _hyper_4_130_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_131_chunk
|
|
Output: _hyper_4_131_chunk."time", _hyper_4_131_chunk.temp, _hyper_4_131_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_132_chunk
|
|
Output: _hyper_4_132_chunk."time", _hyper_4_132_chunk.temp, _hyper_4_132_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_133_chunk
|
|
Output: _hyper_4_133_chunk."time", _hyper_4_133_chunk.temp, _hyper_4_133_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_134_chunk
|
|
Output: _hyper_4_134_chunk."time", _hyper_4_134_chunk.temp, _hyper_4_134_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_135_chunk
|
|
Output: _hyper_4_135_chunk."time", _hyper_4_135_chunk.temp, _hyper_4_135_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_136_chunk
|
|
Output: _hyper_4_136_chunk."time", _hyper_4_136_chunk.temp, _hyper_4_136_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_137_chunk
|
|
Output: _hyper_4_137_chunk."time", _hyper_4_137_chunk.temp, _hyper_4_137_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_138_chunk
|
|
Output: _hyper_4_138_chunk."time", _hyper_4_138_chunk.temp, _hyper_4_138_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_139_chunk
|
|
Output: _hyper_4_139_chunk."time", _hyper_4_139_chunk.temp, _hyper_4_139_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_140_chunk
|
|
Output: _hyper_4_140_chunk."time", _hyper_4_140_chunk.temp, _hyper_4_140_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_141_chunk
|
|
Output: _hyper_4_141_chunk."time", _hyper_4_141_chunk.temp, _hyper_4_141_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_142_chunk
|
|
Output: _hyper_4_142_chunk."time", _hyper_4_142_chunk.temp, _hyper_4_142_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_143_chunk
|
|
Output: _hyper_4_143_chunk."time", _hyper_4_143_chunk.temp, _hyper_4_143_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_144_chunk
|
|
Output: _hyper_4_144_chunk."time", _hyper_4_144_chunk.temp, _hyper_4_144_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_145_chunk
|
|
Output: _hyper_4_145_chunk."time", _hyper_4_145_chunk.temp, _hyper_4_145_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_146_chunk
|
|
Output: _hyper_4_146_chunk."time", _hyper_4_146_chunk.temp, _hyper_4_146_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_147_chunk
|
|
Output: _hyper_4_147_chunk."time", _hyper_4_147_chunk.temp, _hyper_4_147_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_148_chunk
|
|
Output: _hyper_4_148_chunk."time", _hyper_4_148_chunk.temp, _hyper_4_148_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_149_chunk
|
|
Output: _hyper_4_149_chunk."time", _hyper_4_149_chunk.temp, _hyper_4_149_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_150_chunk
|
|
Output: _hyper_4_150_chunk."time", _hyper_4_150_chunk.temp, _hyper_4_150_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_151_chunk
|
|
Output: _hyper_4_151_chunk."time", _hyper_4_151_chunk.temp, _hyper_4_151_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_152_chunk
|
|
Output: _hyper_4_152_chunk."time", _hyper_4_152_chunk.temp, _hyper_4_152_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_153_chunk
|
|
Output: _hyper_4_153_chunk."time", _hyper_4_153_chunk.temp, _hyper_4_153_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_154_chunk
|
|
Output: _hyper_4_154_chunk."time", _hyper_4_154_chunk.temp, _hyper_4_154_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_155_chunk
|
|
Output: _hyper_4_155_chunk."time", _hyper_4_155_chunk.temp, _hyper_4_155_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_156_chunk
|
|
Output: _hyper_4_156_chunk."time", _hyper_4_156_chunk.temp, _hyper_4_156_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_157_chunk
|
|
Output: _hyper_4_157_chunk."time", _hyper_4_157_chunk.temp, _hyper_4_157_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_158_chunk
|
|
Output: _hyper_4_158_chunk."time", _hyper_4_158_chunk.temp, _hyper_4_158_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_159_chunk
|
|
Output: _hyper_4_159_chunk."time", _hyper_4_159_chunk.temp, _hyper_4_159_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_160_chunk
|
|
Output: _hyper_4_160_chunk."time", _hyper_4_160_chunk.temp, _hyper_4_160_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_161_chunk
|
|
Output: _hyper_4_161_chunk."time", _hyper_4_161_chunk.temp, _hyper_4_161_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_162_chunk
|
|
Output: _hyper_4_162_chunk."time", _hyper_4_162_chunk.temp, _hyper_4_162_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_163_chunk
|
|
Output: _hyper_4_163_chunk."time", _hyper_4_163_chunk.temp, _hyper_4_163_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_164_chunk
|
|
Output: _hyper_4_164_chunk."time", _hyper_4_164_chunk.temp, _hyper_4_164_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_165_chunk
|
|
Output: _hyper_4_165_chunk."time", _hyper_4_165_chunk.temp, _hyper_4_165_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_166_chunk
|
|
Output: _hyper_4_166_chunk."time", _hyper_4_166_chunk.temp, _hyper_4_166_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_167_chunk
|
|
Output: _hyper_4_167_chunk."time", _hyper_4_167_chunk.temp, _hyper_4_167_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_168_chunk
|
|
Output: _hyper_4_168_chunk."time", _hyper_4_168_chunk.temp, _hyper_4_168_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_169_chunk
|
|
Output: _hyper_4_169_chunk."time", _hyper_4_169_chunk.temp, _hyper_4_169_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_170_chunk
|
|
Output: _hyper_4_170_chunk."time", _hyper_4_170_chunk.temp, _hyper_4_170_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_171_chunk
|
|
Output: _hyper_4_171_chunk."time", _hyper_4_171_chunk.temp, _hyper_4_171_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_172_chunk
|
|
Output: _hyper_4_172_chunk."time", _hyper_4_172_chunk.temp, _hyper_4_172_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_173_chunk
|
|
Output: _hyper_4_173_chunk."time", _hyper_4_173_chunk.temp, _hyper_4_173_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_174_chunk
|
|
Output: _hyper_4_174_chunk."time", _hyper_4_174_chunk.temp, _hyper_4_174_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_175_chunk
|
|
Output: _hyper_4_175_chunk."time", _hyper_4_175_chunk.temp, _hyper_4_175_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_176_chunk
|
|
Output: _hyper_4_176_chunk."time", _hyper_4_176_chunk.temp, _hyper_4_176_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_177_chunk
|
|
Output: _hyper_4_177_chunk."time", _hyper_4_177_chunk.temp, _hyper_4_177_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_178_chunk
|
|
Output: _hyper_4_178_chunk."time", _hyper_4_178_chunk.temp, _hyper_4_178_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_179_chunk
|
|
Output: _hyper_4_179_chunk."time", _hyper_4_179_chunk.temp, _hyper_4_179_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_180_chunk
|
|
Output: _hyper_4_180_chunk."time", _hyper_4_180_chunk.temp, _hyper_4_180_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_181_chunk
|
|
Output: _hyper_4_181_chunk."time", _hyper_4_181_chunk.temp, _hyper_4_181_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_182_chunk
|
|
Output: _hyper_4_182_chunk."time", _hyper_4_182_chunk.temp, _hyper_4_182_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_183_chunk
|
|
Output: _hyper_4_183_chunk."time", _hyper_4_183_chunk.temp, _hyper_4_183_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_184_chunk
|
|
Output: _hyper_4_184_chunk."time", _hyper_4_184_chunk.temp, _hyper_4_184_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_185_chunk
|
|
Output: _hyper_4_185_chunk."time", _hyper_4_185_chunk.temp, _hyper_4_185_chunk.device
|
|
-> Seq Scan on _timescaledb_internal._hyper_4_186_chunk
|
|
Output: _hyper_4_186_chunk."time", _hyper_4_186_chunk.temp, _hyper_4_186_chunk.device
|
|
(368 rows)
|
|
|
|
INSERT INTO many_partitions_test_1m(time, temp, device)
|
|
SELECT time_bucket('1 minute', time) AS period, avg(temp), device
|
|
FROM many_partitions_test
|
|
GROUP BY period, device;
|
|
SELECT * FROM many_partitions_test_1m ORDER BY time, device LIMIT 10;
|
|
time | temp | device
|
|
--------------------------+------+--------
|
|
Wed Dec 31 16:00:00 1969 | 1 | 1
|
|
Wed Dec 31 16:00:00 1969 | 10 | 10
|
|
Wed Dec 31 16:00:00 1969 | 11 | 11
|
|
Wed Dec 31 16:00:00 1969 | 12 | 12
|
|
Wed Dec 31 16:00:00 1969 | 13 | 13
|
|
Wed Dec 31 16:00:00 1969 | 14 | 14
|
|
Wed Dec 31 16:00:00 1969 | 15 | 15
|
|
Wed Dec 31 16:00:00 1969 | 16 | 16
|
|
Wed Dec 31 16:00:00 1969 | 17 | 17
|
|
Wed Dec 31 16:00:00 1969 | 18 | 18
|
|
(10 rows)
|
|
|
|
CREATE TABLE one_space_test(time timestamp, temp float8, device text NOT NULL);
|
|
SELECT create_hypertable('one_space_test', 'time', 'device', 1);
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
-------------------
|
|
|
|
(1 row)
|
|
|
|
INSERT INTO one_space_test VALUES
|
|
('2001-01-01 01:01:01', 1.0, 'device'),
|
|
('2002-01-01 01:02:01', 1.0, 'device');
|
|
SELECT * FROM one_space_test;
|
|
time | temp | device
|
|
--------------------------+------+--------
|
|
Mon Jan 01 01:01:01 2001 | 1 | device
|
|
Tue Jan 01 01:02:01 2002 | 1 | device
|
|
(2 rows)
|
|
|
|
--CTE & EXPLAIN ANALYZE TESTS
|
|
WITH insert_cte as (
|
|
INSERT INTO one_space_test VALUES
|
|
('2001-01-01 01:02:01', 1.0, 'device')
|
|
RETURNING *)
|
|
SELECT * FROM insert_cte;
|
|
time | temp | device
|
|
--------------------------+------+--------
|
|
Mon Jan 01 01:02:01 2001 | 1 | device
|
|
(1 row)
|
|
|
|
EXPLAIN (analyze, costs off, timing off) --can't turn summary off in 9.6 so instead grep it away at end.
|
|
WITH insert_cte as (
|
|
INSERT INTO one_space_test VALUES
|
|
('2001-01-01 01:03:01', 1.0, 'device')
|
|
)
|
|
SELECT 1 \g | grep -v "Planning" | grep -v "Execution"
|
|
QUERY PLAN
|
|
-------------------------------------------------------------------------
|
|
Result (actual rows=1 loops=1)
|
|
CTE insert_cte
|
|
-> Custom Scan (HypertableInsert) (never executed)
|
|
-> Insert on one_space_test (actual rows=0 loops=1)
|
|
-> Custom Scan (ChunkDispatch) (actual rows=1 loops=1)
|
|
-> Result (actual rows=1 loops=1)
|
|
(8 rows)
|
|
|