mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
Cleanup tests and make errors less verbose
Previously, each test set their own (although mostly the same) configuration for log output and error verbosity. This is now set globally in the test runner so that tests only need to set these configuration parameters if they need to override the defaults. The log verbosity is also reduced so that errors aren't generated with the line number of the source file that output the error. Line numbers in the output can break tests when upgrading to a new PostgreSQL version that outputs a different line number.
This commit is contained in:
parent
3fd8bdbd71
commit
9023de61db
@ -1,30 +1,22 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\set ECHO ALL
|
||||
\ir include/insert_single.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
\set ECHO ALL
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."one_Partition" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -32,71 +24,35 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', associated_schema_name=>'testNs' );
|
||||
CREATE INDEX ON PUBLIC."one_Partition" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM create_hypertable('"public"."one_Partition"', 'timeCustom', associated_schema_name=>'one_Partition' );
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
BEGIN;
|
||||
\COPY "testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY "one_Partition" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'one_Partition'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
close_chunk_end_immediate
|
||||
---------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', chunk_size_bytes => 10000);
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
1 | 1 | dev1
|
||||
2 | 2 | dev2
|
||||
3 | 3 | dev3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
id | partition_id | start_time | end_time | chunk_id | partition_replica_id | database_name | schema_name | table_name | id | partition_id | hypertable_id | replica_id | schema_name | table_name | id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+--------------+------------+----------+----------+----------------------+---------------+-----------------------+---------------------+----+--------------+---------------+------------+-----------------------+------------------------+----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
3 | 2 | | 1 | 3 | 2 | single | _timescaledb_internal | _hyper_2_2_0_3_data | 2 | 2 | 2 | 0 | _timescaledb_internal | _hyper_2_2_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
4 | 2 | 2 | 2 | 4 | 2 | single | _timescaledb_internal | _hyper_2_2_0_4_data | 2 | 2 | 2 | 0 | _timescaledb_internal | _hyper_2_2_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
5 | 2 | 3 | | 5 | 2 | single | _timescaledb_internal | _hyper_2_2_0_5_data | 2 | 2 | 2 | 0 | _timescaledb_internal | _hyper_2_2_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
(3 rows)
|
||||
|
||||
\set VERBOSITY default
|
||||
DO $$
|
||||
BEGIN
|
||||
CREATE ROLE alt_usr LOGIN;
|
||||
@ -106,18 +62,15 @@ EXCEPTION
|
||||
END$$;
|
||||
\c single alt_usr
|
||||
\dt
|
||||
List of relations
|
||||
Schema | Name | Type | Owner
|
||||
--------+--------------------+-------+----------
|
||||
public | chunk_closing_test | table | postgres
|
||||
public | testNs | table | postgres
|
||||
(2 rows)
|
||||
List of relations
|
||||
Schema | Name | Type | Owner
|
||||
--------+---------------+-------+----------
|
||||
public | one_Partition | table | postgres
|
||||
(1 row)
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT * FROM chunk_closing_test;
|
||||
ERROR: permission denied for relation _hyper_2_0_replica
|
||||
--todo fix error message here:
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "one_Partition";
|
||||
ERROR: permission denied for relation _hyper_1_0_replica
|
||||
\set ON_ERROR_STOP 1
|
||||
CREATE TABLE "1dim"(time timestamp, temp float);
|
||||
@ -157,23 +110,22 @@ SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id',
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+-----------------------------+------------+------------------
|
||||
1 | public | testNs | testNs | _hyper_1 | testNs | _hyper_1_root | 1 | STICKY | timeCustom | bigint | single | 1073741824
|
||||
2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
3 | public | 1dim | _timescaledb_internal | _hyper_3 | _timescaledb_internal | _hyper_3_root | 1 | STICKY | time | timestamp without time zone | single | 1073741824
|
||||
4 | public | Hypertable_1 | _timescaledb_internal | _hyper_4 | _timescaledb_internal | _hyper_4_root | 1 | STICKY | time | bigint | single | 1073741824
|
||||
(4 rows)
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+---------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+-----------------------------+------------+------------------
|
||||
1 | public | one_Partition | one_Partition | _hyper_1 | one_Partition | _hyper_1_root | 1 | STICKY | timeCustom | bigint | single | 1073741824
|
||||
2 | public | 1dim | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | timestamp without time zone | single | 1073741824
|
||||
3 | public | Hypertable_1 | _timescaledb_internal | _hyper_3 | _timescaledb_internal | _hyper_3_root | 1 | STICKY | time | bigint | single | 1073741824
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.hypertable_index;
|
||||
hypertable_id | main_schema_name | main_index_name | definition | created_on
|
||||
---------------+------------------+-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+------------
|
||||
1 | public | testNs_device_id_timeCustom_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree (device_id, "timeCustom" DESC NULLS LAST) WHERE (device_id IS NOT NULL) | single
|
||||
1 | public | testNs_timeCustom_series_0_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_0) WHERE (series_0 IS NOT NULL) | single
|
||||
1 | public | testNs_timeCustom_series_1_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_1) WHERE (series_1 IS NOT NULL) | single
|
||||
1 | public | testNs_timeCustom_series_2_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_2) WHERE (series_2 IS NOT NULL) | single
|
||||
1 | public | testNs_timeCustom_series_bool_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE (series_bool IS NOT NULL) | single
|
||||
4 | public | Hypertable_1_time_Device_id_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("time", "Device_id") | single
|
||||
hypertable_id | main_schema_name | main_index_name | definition | created_on
|
||||
---------------+------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+------------
|
||||
1 | public | one_Partition_device_id_timeCustom_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree (device_id, "timeCustom" DESC NULLS LAST) WHERE (device_id IS NOT NULL) | single
|
||||
1 | public | one_Partition_timeCustom_series_0_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_0) WHERE (series_0 IS NOT NULL) | single
|
||||
1 | public | one_Partition_timeCustom_series_1_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_1) WHERE (series_1 IS NOT NULL) | single
|
||||
1 | public | one_Partition_timeCustom_series_2_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_2) WHERE (series_2 IS NOT NULL) | single
|
||||
1 | public | one_Partition_timeCustom_series_bool_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE (series_bool IS NOT NULL) | single
|
||||
3 | public | Hypertable_1_time_Device_id_idx | CREATE INDEX /*INDEX_NAME*/ ON /*TABLE_NAME*/ USING btree ("time", "Device_id") | single
|
||||
(6 rows)
|
||||
|
||||
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "temp_c");
|
||||
|
56
test/expected/create_chunks.out
Normal file
56
test/expected/create_chunks.out
Normal file
@ -0,0 +1,56 @@
|
||||
\ir include/create_single_db.sql
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
1 | 1 | dev1
|
||||
2 | 2 | dev2
|
||||
3 | 3 | dev3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM ONLY chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
id | partition_id | start_time | end_time | chunk_id | partition_replica_id | database_name | schema_name | table_name | id | partition_id | hypertable_id | replica_id | schema_name | table_name | id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+--------------+------------+----------+----------+----------------------+---------------+-----------------------+---------------------+----+--------------+---------------+------------+-----------------------+------------------------+----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
1 | 1 | | 1 | 1 | 1 | single | _timescaledb_internal | _hyper_1_1_0_1_data | 1 | 1 | 1 | 0 | _timescaledb_internal | _hyper_1_1_0_partition | 1 | public | chunk_closing_test | _timescaledb_internal | _hyper_1 | _timescaledb_internal | _hyper_1_root | 1 | STICKY | time | bigint | single | 10000
|
||||
2 | 1 | 2 | 2 | 2 | 1 | single | _timescaledb_internal | _hyper_1_1_0_2_data | 1 | 1 | 1 | 0 | _timescaledb_internal | _hyper_1_1_0_partition | 1 | public | chunk_closing_test | _timescaledb_internal | _hyper_1 | _timescaledb_internal | _hyper_1_root | 1 | STICKY | time | bigint | single | 10000
|
||||
3 | 1 | 3 | | 3 | 1 | single | _timescaledb_internal | _hyper_1_1_0_3_data | 1 | 1 | 1 | 0 | _timescaledb_internal | _hyper_1_1_0_partition | 1 | public | chunk_closing_test | _timescaledb_internal | _hyper_1 | _timescaledb_internal | _hyper_1_root | 1 | STICKY | time | bigint | single | 10000
|
||||
(3 rows)
|
||||
|
@ -1,26 +1,19 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY verbose
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
create schema test_schema;
|
||||
create table test_schema.test_table(time bigint, temp float8, device_id text);
|
||||
\dt "test_schema".*
|
||||
|
@ -1,22 +1,16 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\ir include/ddl_ops_1.sql
|
||||
CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
time BIGINT NOT NULL,
|
||||
@ -55,11 +49,9 @@ VALUES(1257894000000000000, 'dev1', 30, 70, 1, 2, 3, 100);
|
||||
--expect error cases
|
||||
\set ON_ERROR_STOP 0
|
||||
UPDATE ONLY PUBLIC."Hypertable_1" SET time = 0 WHERE TRUE;
|
||||
psql:include/ddl_ops_1.sql:25: ERROR: IO101: UPDATE ONLY not supported on hypertables
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_1.sql:25: ERROR: UPDATE ONLY not supported on hypertables
|
||||
DELETE FROM ONLY PUBLIC."Hypertable_1" WHERE "Device_id" = 'dev1';
|
||||
psql:include/ddl_ops_1.sql:26: ERROR: IO101: DELETE ONLY not currently supported on hypertables
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_1.sql:26: ERROR: DELETE ONLY not currently supported on hypertables
|
||||
\set ON_ERROR_STOP 1
|
||||
SELECT * FROM PUBLIC."Hypertable_1";
|
||||
time | Device_id | temp_c | humidity | sensor_1 | sensor_2 | sensor_3 | sensor_4
|
||||
@ -171,15 +163,12 @@ $BODY$;
|
||||
--expect error cases
|
||||
\set ON_ERROR_STOP 0
|
||||
ALTER TABLE PUBLIC."Hypertable_1" ALTER COLUMN sensor_2_renamed SET DATA TYPE int;
|
||||
psql:include/ddl_ops_2.sql:23: ERROR: IO101: ALTER TABLE ... ALTER COLUMN SET DATA TYPE not supported on hypertable "Hypertable_1"
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_2.sql:23: ERROR: ALTER TABLE ... ALTER COLUMN SET DATA TYPE not supported on hypertable "Hypertable_1"
|
||||
ALTER INDEX "ind_humidity" RENAME TO "ind_humdity2";
|
||||
psql:include/ddl_ops_2.sql:24: ERROR: IO101: ALTER INDEX not supported on hypertable "Hypertable_1"
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_2.sql:24: ERROR: ALTER INDEX not supported on hypertable "Hypertable_1"
|
||||
CREATE TRIGGER test_trigger BEFORE UPDATE OR DELETE ON PUBLIC."Hypertable_1"
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE empty_trigger_func();
|
||||
psql:include/ddl_ops_2.sql:26: ERROR: IO101: CREATE TRIGGER not supported on hypertable "Hypertable_1"
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_2.sql:26: ERROR: CREATE TRIGGER not supported on hypertable "Hypertable_1"
|
||||
\set ON_ERROR_STOP 1
|
||||
--create column with same name as previously renamed one
|
||||
ALTER TABLE PUBLIC."Hypertable_1" ADD COLUMN sensor_3 BIGINT NOT NULL DEFAULT 131;
|
||||
|
@ -1,28 +1,20 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
-- Expect error when adding user again
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT add_cluster_user();
|
||||
ERROR: IO130: User postgres already exists
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
ERROR: User postgres already exists
|
||||
\set ON_ERROR_STOP 1
|
||||
-- Expect error when adding node again
|
||||
CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
@ -33,23 +25,16 @@ CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id");
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1_mispelled"', 'time', 'Device_id', 2);
|
||||
ERROR: 42P01: relation "public.Hypertable_1_mispelled" does not exist
|
||||
LINE 1: SELECT * FROM create_hypertable('"public"."Hypertable_1_misp...
|
||||
^
|
||||
LOCATION: RangeVarGetRelidExtended, namespace.c:415
|
||||
ERROR: relation "public.Hypertable_1_mispelled" does not exist at character 33
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time_mispelled', 'Device_id', 2);
|
||||
ERROR: IO102: column "time_mispelled" does not exist
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
ERROR: column "time_mispelled" does not exist
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'Device_id', 'Device_id', 2);
|
||||
ERROR: IO102: illegal type for time column "Device_id": text
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
ERROR: illegal type for time column "Device_id": text
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id_mispelled', 2);
|
||||
ERROR: IO102: column "Device_id_mispelled" does not exist
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
ERROR: column "Device_id_mispelled" does not exist
|
||||
INSERT INTO PUBLIC."Hypertable_1" VALUES(1,'dev_1', 3);
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id', 2);
|
||||
ERROR: IO102: the table being converted to a hypertable must be empty
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
ERROR: the table being converted to a hypertable must be empty
|
||||
DELETE FROM PUBLIC."Hypertable_1" ;
|
||||
\set ON_ERROR_STOP 1
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id', 2);
|
||||
@ -60,5 +45,4 @@ SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id',
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id', 2);
|
||||
ERROR: IO110: hypertable "Hypertable_1" already exists
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
ERROR: hypertable "Hypertable_1" already exists
|
||||
|
@ -1,23 +1,16 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
\ir include/ddl_ops_1.sql
|
||||
CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
time BIGINT NOT NULL,
|
||||
@ -56,11 +49,9 @@ VALUES(1257894000000000000, 'dev1', 30, 70, 1, 2, 3, 100);
|
||||
--expect error cases
|
||||
\set ON_ERROR_STOP 0
|
||||
UPDATE ONLY PUBLIC."Hypertable_1" SET time = 0 WHERE TRUE;
|
||||
psql:include/ddl_ops_1.sql:25: ERROR: IO101: UPDATE ONLY not supported on hypertables
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_1.sql:25: ERROR: UPDATE ONLY not supported on hypertables
|
||||
DELETE FROM ONLY PUBLIC."Hypertable_1" WHERE "Device_id" = 'dev1';
|
||||
psql:include/ddl_ops_1.sql:26: ERROR: IO101: DELETE ONLY not currently supported on hypertables
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_1.sql:26: ERROR: DELETE ONLY not currently supported on hypertables
|
||||
\set ON_ERROR_STOP 1
|
||||
SELECT * FROM PUBLIC."Hypertable_1";
|
||||
time | Device_id | temp_c | humidity | sensor_1 | sensor_2 | sensor_3 | sensor_4
|
||||
@ -104,15 +95,12 @@ $BODY$;
|
||||
--expect error cases
|
||||
\set ON_ERROR_STOP 0
|
||||
ALTER TABLE PUBLIC."Hypertable_1" ALTER COLUMN sensor_2_renamed SET DATA TYPE int;
|
||||
psql:include/ddl_ops_2.sql:23: ERROR: IO101: ALTER TABLE ... ALTER COLUMN SET DATA TYPE not supported on hypertable "Hypertable_1"
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_2.sql:23: ERROR: ALTER TABLE ... ALTER COLUMN SET DATA TYPE not supported on hypertable "Hypertable_1"
|
||||
ALTER INDEX "ind_humidity" RENAME TO "ind_humdity2";
|
||||
psql:include/ddl_ops_2.sql:24: ERROR: IO101: ALTER INDEX not supported on hypertable "Hypertable_1"
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_2.sql:24: ERROR: ALTER INDEX not supported on hypertable "Hypertable_1"
|
||||
CREATE TRIGGER test_trigger BEFORE UPDATE OR DELETE ON PUBLIC."Hypertable_1"
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE empty_trigger_func();
|
||||
psql:include/ddl_ops_2.sql:26: ERROR: IO101: CREATE TRIGGER not supported on hypertable "Hypertable_1"
|
||||
LOCATION: exec_stmt_raise, pl_exec.c:3165
|
||||
psql:include/ddl_ops_2.sql:26: ERROR: CREATE TRIGGER not supported on hypertable "Hypertable_1"
|
||||
\set ON_ERROR_STOP 1
|
||||
--create column with same name as previously renamed one
|
||||
ALTER TABLE PUBLIC."Hypertable_1" ADD COLUMN sensor_3 BIGINT NOT NULL DEFAULT 131;
|
||||
|
@ -1,22 +1,18 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."two_Partitions" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -24,45 +20,28 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, device_id);
|
||||
SELECT * FROM create_hypertable('"public"."testNs"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
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);
|
||||
BEGIN;
|
||||
\COPY public."testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'two_Partitions'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
INSERT INTO public."testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
\o
|
||||
\set ECHO ALL
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "two_Partitions";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
||||
@ -77,9 +56,9 @@ SELECT * FROM "testNs";
|
||||
1257894000000000000 | dev20 | 1.5 | 2 | |
|
||||
(10 rows)
|
||||
|
||||
DELETE FROM "testNs" WHERE series_0 = 1.5;
|
||||
DELETE FROM "testNs" WHERE series_0 = 100;
|
||||
SELECT * FROM "testNs";
|
||||
DELETE FROM "two_Partitions" WHERE series_0 = 1.5;
|
||||
DELETE FROM "two_Partitions" WHERE series_0 = 100;
|
||||
SELECT * FROM "two_Partitions";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000001000 | dev1 | 2.5 | 3 | |
|
||||
|
@ -1,23 +1,16 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
CREATE TABLE PUBLIC.drop_chunk_test1(time bigint, temp float8, device_id text);
|
||||
CREATE TABLE PUBLIC.drop_chunk_test2(time bigint, temp float8, device_id text);
|
||||
SELECT create_hypertable('public.drop_chunk_test1', 'time', chunk_size_bytes => 10000);
|
||||
|
@ -1,23 +1,16 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
CREATE TABLE drop_test(time timestamp, temp float8, device text);
|
||||
SELECT create_hypertable('drop_test', 'time', 'device', 2);
|
||||
create_hypertable
|
||||
@ -38,24 +31,8 @@ SELECT * FROM drop_test;
|
||||
Mon Mar 20 09:17:00.936242 2017 | 23.4 | dev1
|
||||
(1 row)
|
||||
|
||||
-- Drop the extension
|
||||
DROP EXTENSION timescaledb CASCADE;
|
||||
NOTICE: 00000: drop cascades to 14 other objects
|
||||
DETAIL: drop cascades to table _timescaledb_internal._hyper_1_root
|
||||
drop cascades to table _timescaledb_internal._hyper_1_0_replica
|
||||
drop cascades to table _timescaledb_internal._hyper_1_1_0_partition
|
||||
drop cascades to table _timescaledb_internal._hyper_1_2_0_partition
|
||||
drop cascades to table _timescaledb_internal._hyper_1_1_0_1_data
|
||||
drop cascades to trigger _timescaledb_modify_trigger on table drop_test
|
||||
drop cascades to trigger _timescaledb_main_insert_trigger on table drop_test
|
||||
drop cascades to trigger _timescaledb_main_after_insert_trigger on table drop_test
|
||||
drop cascades to event trigger ddl_create_index
|
||||
drop cascades to event trigger ddl_create_trigger
|
||||
drop cascades to event trigger ddl_alter_index
|
||||
drop cascades to event trigger ddl_drop_index
|
||||
drop cascades to event trigger ddl_create_column
|
||||
drop cascades to event trigger ddl_check_drop_command
|
||||
LOCATION: reportDependentObjects, dependency.c:1011
|
||||
NOTICE: drop cascades to 14 other objects
|
||||
-- Querying the original table should not return any rows since all of
|
||||
-- them actually existed in chunks that are now gone
|
||||
SELECT * FROM drop_test;
|
||||
@ -68,8 +45,7 @@ CREATE EXTENSION timescaledb CASCADE;
|
||||
-- Test that calling twice generates proper error
|
||||
\set ON_ERROR_STOP 0
|
||||
CREATE EXTENSION timescaledb CASCADE;
|
||||
ERROR: 42710: extension "timescaledb" already exists
|
||||
LOCATION: CreateExtension, extension.c:1542
|
||||
ERROR: extension "timescaledb" already exists
|
||||
\set ON_ERROR_STOP 1
|
||||
SELECT setup_timescaledb();
|
||||
setup_timescaledb
|
||||
|
@ -1,24 +1,18 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."two_Partitions" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -26,166 +20,148 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, device_id);
|
||||
SELECT * FROM create_hypertable('"public"."testNs"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
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);
|
||||
BEGIN;
|
||||
\COPY public."testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'two_Partitions'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
INSERT INTO public."testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
\d+ "_timescaledb_internal".*
|
||||
Index "_timescaledb_internal.1-testNs_device_id_timeCustom_idx"
|
||||
Index "_timescaledb_internal.1-two_Partitions_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.10-testNs_timeCustom_series_2_idx"
|
||||
Index "_timescaledb_internal.10-two_Partitions_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.11-testNs_timeCustom_series_bool_idx"
|
||||
Index "_timescaledb_internal.11-two_Partitions_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.12-testNs_timeCustom_device_id_idx"
|
||||
Index "_timescaledb_internal.12-two_Partitions_timeCustom_device_id_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
device_id | text | device_id | extended
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data"
|
||||
|
||||
Index "_timescaledb_internal.13-testNs_device_id_timeCustom_idx"
|
||||
Index "_timescaledb_internal.13-two_Partitions_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.14-testNs_timeCustom_series_0_idx"
|
||||
Index "_timescaledb_internal.14-two_Partitions_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.15-testNs_timeCustom_series_1_idx"
|
||||
Index "_timescaledb_internal.15-two_Partitions_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_1 | double precision | series_1 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_1 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.16-testNs_timeCustom_series_2_idx"
|
||||
Index "_timescaledb_internal.16-two_Partitions_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.17-testNs_timeCustom_series_bool_idx"
|
||||
Index "_timescaledb_internal.17-two_Partitions_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.18-testNs_timeCustom_device_id_idx"
|
||||
Index "_timescaledb_internal.18-two_Partitions_timeCustom_device_id_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
device_id | text | device_id | extended
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data"
|
||||
|
||||
Index "_timescaledb_internal.2-testNs_timeCustom_series_0_idx"
|
||||
Index "_timescaledb_internal.2-two_Partitions_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.3-testNs_timeCustom_series_1_idx"
|
||||
Index "_timescaledb_internal.3-two_Partitions_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_1 | double precision | series_1 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.4-testNs_timeCustom_series_2_idx"
|
||||
Index "_timescaledb_internal.4-two_Partitions_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.5-testNs_timeCustom_series_bool_idx"
|
||||
Index "_timescaledb_internal.5-two_Partitions_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.6-testNs_timeCustom_device_id_idx"
|
||||
Index "_timescaledb_internal.6-two_Partitions_timeCustom_device_id_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
device_id | text | device_id | extended
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data"
|
||||
|
||||
Index "_timescaledb_internal.7-testNs_device_id_timeCustom_idx"
|
||||
Index "_timescaledb_internal.7-two_Partitions_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.8-testNs_timeCustom_series_0_idx"
|
||||
Index "_timescaledb_internal.8-two_Partitions_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.9-testNs_timeCustom_series_1_idx"
|
||||
Index "_timescaledb_internal.9-two_Partitions_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
@ -215,12 +191,12 @@ Child tables: _timescaledb_internal._hyper_1_1_0_partition,
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"1-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"2-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"3-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"4-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"5-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"6-testNs_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"1-two_Partitions_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"2-two_Partitions_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"3-two_Partitions_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"4-two_Partitions_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"5-two_Partitions_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"6-two_Partitions_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("timeCustom" <= '1257897600000000000'::bigint) NOT VALID
|
||||
@ -236,12 +212,12 @@ Inherits: _timescaledb_internal._hyper_1_1_0_partition
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"10-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"11-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"12-testNs_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"7-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"8-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"9-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"10-two_Partitions_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"11-two_Partitions_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"12-two_Partitions_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"7-two_Partitions_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"8-two_Partitions_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"9-two_Partitions_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("timeCustom" >= '1257897600000000001'::bigint) NOT VALID
|
||||
@ -272,12 +248,12 @@ Child tables: _timescaledb_internal._hyper_1_1_0_1_data,
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"13-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"14-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"15-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"16-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"17-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"18-testNs_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"13-two_Partitions_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"14-two_Partitions_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"15-two_Partitions_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"16-two_Partitions_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"17-two_Partitions_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"18-two_Partitions_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '16384'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '32767'::smallint)
|
||||
Inherits: _timescaledb_internal._hyper_1_2_0_partition
|
||||
@ -307,84 +283,10 @@ Child tables: _timescaledb_internal._hyper_1_2_0_3_data
|
||||
series_bool | boolean | | plain | |
|
||||
Child tables: _timescaledb_internal._hyper_1_0_replica
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_0_replica"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Inherits: _timescaledb_internal._hyper_2_root
|
||||
Child tables: _timescaledb_internal._hyper_2_3_0_partition,
|
||||
_timescaledb_internal._hyper_2_4_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_4_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("time" <= '1'::bigint) NOT VALID
|
||||
Inherits: _timescaledb_internal._hyper_2_3_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_5_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("time" >= '2'::bigint AND "time" <= '2'::bigint) NOT VALID
|
||||
Inherits: _timescaledb_internal._hyper_2_3_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_6_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("time" >= '3'::bigint) NOT VALID
|
||||
Inherits: _timescaledb_internal._hyper_2_3_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_partition"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
Inherits: _timescaledb_internal._hyper_2_0_replica
|
||||
Child tables: _timescaledb_internal._hyper_2_3_0_4_data,
|
||||
_timescaledb_internal._hyper_2_3_0_5_data,
|
||||
_timescaledb_internal._hyper_2_3_0_6_data
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_4_0_partition"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '16384'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '32767'::smallint)
|
||||
Inherits: _timescaledb_internal._hyper_2_0_replica
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Child tables: _timescaledb_internal._hyper_2_0_replica
|
||||
|
||||
-- Test that renaming hypertable is blocked
|
||||
\set VERBOSITY default
|
||||
\set ON_ERROR_STOP 0
|
||||
ALTER TABLE "testNs" RENAME TO "newname";
|
||||
ALTER TABLE "two_Partitions" RENAME TO "newname";
|
||||
ERROR: Renaming hypertables is not yet supported
|
||||
\set ON_ERROR_STOP 1
|
||||
-- Test that renaming ordinary table works
|
||||
@ -396,13 +298,12 @@ SELECT * FROM "newname";
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
1 | public | testNs | _timescaledb_internal | _hyper_1 | _timescaledb_internal | _hyper_1_root | 1 | STICKY | timeCustom | bigint | single | 1073741824
|
||||
2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
(2 rows)
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+----------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
1 | public | two_Partitions | _timescaledb_internal | _hyper_1 | _timescaledb_internal | _hyper_1_root | 1 | STICKY | timeCustom | bigint | single | 1073741824
|
||||
(1 row)
|
||||
|
||||
DROP TABLE "testNs";
|
||||
DROP TABLE "two_Partitions";
|
||||
NOTICE: drop cascades to 6 other objects
|
||||
DETAIL: drop cascades to table _timescaledb_internal._hyper_1_0_replica
|
||||
drop cascades to table _timescaledb_internal._hyper_1_1_0_partition
|
||||
@ -410,37 +311,35 @@ drop cascades to table _timescaledb_internal._hyper_1_1_0_1_data
|
||||
drop cascades to table _timescaledb_internal._hyper_1_1_0_2_data
|
||||
drop cascades to table _timescaledb_internal._hyper_1_2_0_partition
|
||||
drop cascades to table _timescaledb_internal._hyper_1_2_0_3_data
|
||||
NOTICE: index "1-testNs_device_id_timeCustom_idx" does not exist, skipping
|
||||
NOTICE: index "7-testNs_device_id_timeCustom_idx" does not exist, skipping
|
||||
NOTICE: index "13-testNs_device_id_timeCustom_idx" does not exist, skipping
|
||||
NOTICE: index "2-testNs_timeCustom_series_0_idx" does not exist, skipping
|
||||
NOTICE: index "8-testNs_timeCustom_series_0_idx" does not exist, skipping
|
||||
NOTICE: index "14-testNs_timeCustom_series_0_idx" does not exist, skipping
|
||||
NOTICE: index "3-testNs_timeCustom_series_1_idx" does not exist, skipping
|
||||
NOTICE: index "9-testNs_timeCustom_series_1_idx" does not exist, skipping
|
||||
NOTICE: index "15-testNs_timeCustom_series_1_idx" does not exist, skipping
|
||||
NOTICE: index "4-testNs_timeCustom_series_2_idx" does not exist, skipping
|
||||
NOTICE: index "10-testNs_timeCustom_series_2_idx" does not exist, skipping
|
||||
NOTICE: index "16-testNs_timeCustom_series_2_idx" does not exist, skipping
|
||||
NOTICE: index "5-testNs_timeCustom_series_bool_idx" does not exist, skipping
|
||||
NOTICE: index "11-testNs_timeCustom_series_bool_idx" does not exist, skipping
|
||||
NOTICE: index "17-testNs_timeCustom_series_bool_idx" does not exist, skipping
|
||||
NOTICE: index "6-testNs_timeCustom_device_id_idx" does not exist, skipping
|
||||
NOTICE: index "12-testNs_timeCustom_device_id_idx" does not exist, skipping
|
||||
NOTICE: index "18-testNs_timeCustom_device_id_idx" does not exist, skipping
|
||||
NOTICE: index "1-two_Partitions_device_id_timeCustom_idx" does not exist, skipping
|
||||
NOTICE: index "7-two_Partitions_device_id_timeCustom_idx" does not exist, skipping
|
||||
NOTICE: index "13-two_Partitions_device_id_timeCustom_idx" does not exist, skipping
|
||||
NOTICE: index "2-two_Partitions_timeCustom_series_0_idx" does not exist, skipping
|
||||
NOTICE: index "8-two_Partitions_timeCustom_series_0_idx" does not exist, skipping
|
||||
NOTICE: index "14-two_Partitions_timeCustom_series_0_idx" does not exist, skipping
|
||||
NOTICE: index "3-two_Partitions_timeCustom_series_1_idx" does not exist, skipping
|
||||
NOTICE: index "9-two_Partitions_timeCustom_series_1_idx" does not exist, skipping
|
||||
NOTICE: index "15-two_Partitions_timeCustom_series_1_idx" does not exist, skipping
|
||||
NOTICE: index "4-two_Partitions_timeCustom_series_2_idx" does not exist, skipping
|
||||
NOTICE: index "10-two_Partitions_timeCustom_series_2_idx" does not exist, skipping
|
||||
NOTICE: index "16-two_Partitions_timeCustom_series_2_idx" does not exist, skipping
|
||||
NOTICE: index "5-two_Partitions_timeCustom_series_bool_idx" does not exist, skipping
|
||||
NOTICE: index "11-two_Partitions_timeCustom_series_bool_idx" does not exist, skipping
|
||||
NOTICE: index "17-two_Partitions_timeCustom_series_bool_idx" does not exist, skipping
|
||||
NOTICE: index "6-two_Partitions_timeCustom_device_id_idx" does not exist, skipping
|
||||
NOTICE: index "12-two_Partitions_timeCustom_device_id_idx" does not exist, skipping
|
||||
NOTICE: index "18-two_Partitions_timeCustom_device_id_idx" does not exist, skipping
|
||||
SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
(1 row)
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+------------+------------------------+-------------------------+------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
(0 rows)
|
||||
|
||||
\dt "public".*
|
||||
List of relations
|
||||
Schema | Name | Type | Owner
|
||||
--------+--------------------+-------+----------
|
||||
public | chunk_closing_test | table | postgres
|
||||
public | newname | table | postgres
|
||||
(2 rows)
|
||||
List of relations
|
||||
Schema | Name | Type | Owner
|
||||
--------+---------+-------+----------
|
||||
public | newname | table | postgres
|
||||
(1 row)
|
||||
|
||||
\dt "_timescaledb_catalog".*
|
||||
List of relations
|
||||
@ -466,15 +365,8 @@ SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
(17 rows)
|
||||
|
||||
\dt+ "_timescaledb_internal".*
|
||||
List of relations
|
||||
Schema | Name | Type | Owner | Size | Description
|
||||
-----------------------+------------------------+-------+----------+------------+-------------
|
||||
_timescaledb_internal | _hyper_2_0_replica | table | postgres | 8192 bytes |
|
||||
_timescaledb_internal | _hyper_2_3_0_4_data | table | postgres | 16 kB |
|
||||
_timescaledb_internal | _hyper_2_3_0_5_data | table | postgres | 16 kB |
|
||||
_timescaledb_internal | _hyper_2_3_0_6_data | table | postgres | 16 kB |
|
||||
_timescaledb_internal | _hyper_2_3_0_partition | table | postgres | 8192 bytes |
|
||||
_timescaledb_internal | _hyper_2_4_0_partition | table | postgres | 8192 bytes |
|
||||
_timescaledb_internal | _hyper_2_root | table | postgres | 8192 bytes |
|
||||
(7 rows)
|
||||
List of relations
|
||||
Schema | Name | Type | Owner | Size | Description
|
||||
--------+------+------+-------+------+-------------
|
||||
(0 rows)
|
||||
|
||||
|
@ -1,27 +1,22 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set ECHO ALL
|
||||
\ir include/insert_two_partitions.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."two_Partitions" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -29,192 +24,157 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, device_id);
|
||||
SELECT * FROM create_hypertable('"public"."testNs"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
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);
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
BEGIN;
|
||||
\COPY public."testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'two_Partitions'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
close_chunk_end_immediate
|
||||
---------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO public."testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
1 | 1 | dev1
|
||||
2 | 2 | dev2
|
||||
3 | 3 | dev3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
id | partition_id | start_time | end_time | chunk_id | partition_replica_id | database_name | schema_name | table_name | id | partition_id | hypertable_id | replica_id | schema_name | table_name | id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+--------------+------------+----------+----------+----------------------+---------------+-----------------------+---------------------+----+--------------+---------------+------------+-----------------------+------------------------+----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
4 | 3 | | 1 | 4 | 3 | single | _timescaledb_internal | _hyper_2_3_0_4_data | 3 | 3 | 2 | 0 | _timescaledb_internal | _hyper_2_3_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
5 | 3 | 2 | 2 | 5 | 3 | single | _timescaledb_internal | _hyper_2_3_0_5_data | 3 | 3 | 2 | 0 | _timescaledb_internal | _hyper_2_3_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
6 | 3 | 3 | | 6 | 3 | single | _timescaledb_internal | _hyper_2_3_0_6_data | 3 | 3 | 2 | 0 | _timescaledb_internal | _hyper_2_3_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
(3 rows)
|
||||
|
||||
\d+ "_timescaledb_internal".*
|
||||
Index "_timescaledb_internal.1-testNs_device_id_timeCustom_idx"
|
||||
Index "_timescaledb_internal.1-two_Partitions_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.10-testNs_timeCustom_series_2_idx"
|
||||
Index "_timescaledb_internal.10-two_Partitions_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.11-testNs_timeCustom_series_bool_idx"
|
||||
Index "_timescaledb_internal.11-two_Partitions_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.12-testNs_timeCustom_device_id_idx"
|
||||
Index "_timescaledb_internal.12-two_Partitions_timeCustom_device_id_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
device_id | text | device_id | extended
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data"
|
||||
|
||||
Index "_timescaledb_internal.13-testNs_device_id_timeCustom_idx"
|
||||
Index "_timescaledb_internal.13-two_Partitions_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.14-testNs_timeCustom_series_0_idx"
|
||||
Index "_timescaledb_internal.14-two_Partitions_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.15-testNs_timeCustom_series_1_idx"
|
||||
Index "_timescaledb_internal.15-two_Partitions_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_1 | double precision | series_1 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_1 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.16-testNs_timeCustom_series_2_idx"
|
||||
Index "_timescaledb_internal.16-two_Partitions_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.17-testNs_timeCustom_series_bool_idx"
|
||||
Index "_timescaledb_internal.17-two_Partitions_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.18-testNs_timeCustom_device_id_idx"
|
||||
Index "_timescaledb_internal.18-two_Partitions_timeCustom_device_id_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
device_id | text | device_id | extended
|
||||
btree, for table "_timescaledb_internal._hyper_1_2_0_3_data"
|
||||
|
||||
Index "_timescaledb_internal.2-testNs_timeCustom_series_0_idx"
|
||||
Index "_timescaledb_internal.2-two_Partitions_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.3-testNs_timeCustom_series_1_idx"
|
||||
Index "_timescaledb_internal.3-two_Partitions_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_1 | double precision | series_1 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.4-testNs_timeCustom_series_2_idx"
|
||||
Index "_timescaledb_internal.4-two_Partitions_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.5-testNs_timeCustom_series_bool_idx"
|
||||
Index "_timescaledb_internal.5-two_Partitions_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.6-testNs_timeCustom_device_id_idx"
|
||||
Index "_timescaledb_internal.6-two_Partitions_timeCustom_device_id_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
device_id | text | device_id | extended
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_1_data"
|
||||
|
||||
Index "_timescaledb_internal.7-testNs_device_id_timeCustom_idx"
|
||||
Index "_timescaledb_internal.7-two_Partitions_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.8-testNs_timeCustom_series_0_idx"
|
||||
Index "_timescaledb_internal.8-two_Partitions_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "_timescaledb_internal._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "_timescaledb_internal.9-testNs_timeCustom_series_1_idx"
|
||||
Index "_timescaledb_internal.9-two_Partitions_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
@ -244,12 +204,12 @@ Child tables: _timescaledb_internal._hyper_1_1_0_partition,
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"1-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"2-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"3-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"4-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"5-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"6-testNs_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"1-two_Partitions_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"2-two_Partitions_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"3-two_Partitions_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"4-two_Partitions_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"5-two_Partitions_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"6-two_Partitions_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("timeCustom" <= '1257897600000000000'::bigint) NOT VALID
|
||||
@ -265,12 +225,12 @@ Inherits: _timescaledb_internal._hyper_1_1_0_partition
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"10-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"11-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"12-testNs_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"7-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"8-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"9-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"10-two_Partitions_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"11-two_Partitions_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"12-two_Partitions_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"7-two_Partitions_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"8-two_Partitions_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"9-two_Partitions_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("timeCustom" >= '1257897600000000001'::bigint) NOT VALID
|
||||
@ -301,12 +261,12 @@ Child tables: _timescaledb_internal._hyper_1_1_0_1_data,
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"13-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"14-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"15-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"16-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"17-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"18-testNs_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
"13-two_Partitions_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"14-two_Partitions_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"15-two_Partitions_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"16-two_Partitions_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"17-two_Partitions_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"18-two_Partitions_timeCustom_device_id_idx" btree ("timeCustom" DESC NULLS LAST, device_id)
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '16384'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '32767'::smallint)
|
||||
Inherits: _timescaledb_internal._hyper_1_2_0_partition
|
||||
@ -336,80 +296,6 @@ Child tables: _timescaledb_internal._hyper_1_2_0_3_data
|
||||
series_bool | boolean | | plain | |
|
||||
Child tables: _timescaledb_internal._hyper_1_0_replica
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_0_replica"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Inherits: _timescaledb_internal._hyper_2_root
|
||||
Child tables: _timescaledb_internal._hyper_2_3_0_partition,
|
||||
_timescaledb_internal._hyper_2_4_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_4_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("time" <= '1'::bigint) NOT VALID
|
||||
Inherits: _timescaledb_internal._hyper_2_3_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_5_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("time" >= '2'::bigint AND "time" <= '2'::bigint) NOT VALID
|
||||
Inherits: _timescaledb_internal._hyper_2_3_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_6_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
"time_range" CHECK ("time" >= '3'::bigint) NOT VALID
|
||||
Inherits: _timescaledb_internal._hyper_2_3_0_partition
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_3_0_partition"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '0'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '16383'::smallint)
|
||||
Inherits: _timescaledb_internal._hyper_2_0_replica
|
||||
Child tables: _timescaledb_internal._hyper_2_3_0_4_data,
|
||||
_timescaledb_internal._hyper_2_3_0_5_data,
|
||||
_timescaledb_internal._hyper_2_3_0_6_data
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_4_0_partition"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Check constraints:
|
||||
"partition" CHECK (_timescaledb_catalog.get_partition_for_key(device_id, 32768) >= '16384'::smallint AND _timescaledb_catalog.get_partition_for_key(device_id, 32768) <= '32767'::smallint)
|
||||
Inherits: _timescaledb_internal._hyper_2_0_replica
|
||||
|
||||
Table "_timescaledb_internal._hyper_2_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------+---------+-----------+----------+--------------+-------------
|
||||
time | bigint | | plain | |
|
||||
metric | integer | | plain | |
|
||||
device_id | text | | extended | |
|
||||
Child tables: _timescaledb_internal._hyper_2_0_replica
|
||||
|
||||
SELECT *
|
||||
FROM "_timescaledb_internal"._hyper_1_0_replica;
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
@ -432,10 +318,7 @@ SELECT * FROM _timescaledb_catalog.chunk;
|
||||
1 | 1 | | 1257897600000000000
|
||||
2 | 1 | 1257897600000000001 |
|
||||
3 | 2 | |
|
||||
4 | 3 | | 1
|
||||
5 | 3 | 2 | 2
|
||||
6 | 3 | 3 |
|
||||
(6 rows)
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.chunk_replica_node;
|
||||
chunk_id | partition_replica_id | database_name | schema_name | table_name
|
||||
@ -443,34 +326,16 @@ SELECT * FROM _timescaledb_catalog.chunk_replica_node;
|
||||
1 | 1 | single | _timescaledb_internal | _hyper_1_1_0_1_data
|
||||
2 | 1 | single | _timescaledb_internal | _hyper_1_1_0_2_data
|
||||
3 | 2 | single | _timescaledb_internal | _hyper_1_2_0_3_data
|
||||
4 | 3 | single | _timescaledb_internal | _hyper_2_3_0_4_data
|
||||
5 | 3 | single | _timescaledb_internal | _hyper_2_3_0_5_data
|
||||
6 | 3 | single | _timescaledb_internal | _hyper_2_3_0_6_data
|
||||
(6 rows)
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.partition_replica;
|
||||
id | partition_id | hypertable_id | replica_id | schema_name | table_name
|
||||
----+--------------+---------------+------------+-----------------------+------------------------
|
||||
1 | 1 | 1 | 0 | _timescaledb_internal | _hyper_1_1_0_partition
|
||||
2 | 2 | 1 | 0 | _timescaledb_internal | _hyper_1_2_0_partition
|
||||
3 | 3 | 2 | 0 | _timescaledb_internal | _hyper_2_3_0_partition
|
||||
4 | 4 | 2 | 0 | _timescaledb_internal | _hyper_2_4_0_partition
|
||||
(4 rows)
|
||||
(2 rows)
|
||||
|
||||
SELECT * FROM chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
1 | 1 | dev1
|
||||
2 | 2 | dev2
|
||||
3 | 3 | dev3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM ONLY chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "two_Partitions";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
||||
@ -485,7 +350,7 @@ SELECT * FROM "testNs";
|
||||
1257894000000000000 | dev20 | 1.5 | 2 | |
|
||||
(10 rows)
|
||||
|
||||
SELECT * FROM ONLY "testNs";
|
||||
SELECT * FROM ONLY "two_Partitions";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
------------+-----------+----------+----------+----------+-------------
|
||||
(0 rows)
|
||||
@ -501,12 +366,7 @@ INSERT INTO error_test VALUES ('Mon Mar 20 09:18:20.1 2017', 21.3, 'dev1');
|
||||
\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: 23502: null value in column "device" violates not-null constraint
|
||||
DETAIL: Failing row contains (Mon Mar 20 09:18:22.3 2017, 21.1, null).
|
||||
SCHEMA NAME: _timescaledb_internal
|
||||
TABLE NAME: _hyper_3_5_0_7_data
|
||||
COLUMN NAME: device
|
||||
LOCATION: ExecConstraints, execMain.c:1732
|
||||
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');
|
||||
SELECT * FROM error_test;
|
||||
|
@ -1,28 +1,22 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set ECHO ALL
|
||||
\ir include/insert_single.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
\set ECHO ALL
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."one_Partition" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -30,143 +24,107 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', associated_schema_name=>'testNs' );
|
||||
CREATE INDEX ON PUBLIC."one_Partition" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM create_hypertable('"public"."one_Partition"', 'timeCustom', associated_schema_name=>'one_Partition' );
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
BEGIN;
|
||||
\COPY "testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY "one_Partition" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'one_Partition'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
close_chunk_end_immediate
|
||||
---------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', chunk_size_bytes => 10000);
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
time | metric | device_id
|
||||
------+--------+-----------
|
||||
1 | 1 | dev1
|
||||
2 | 2 | dev2
|
||||
3 | 3 | dev3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
id | partition_id | start_time | end_time | chunk_id | partition_replica_id | database_name | schema_name | table_name | id | partition_id | hypertable_id | replica_id | schema_name | table_name | id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+--------------+------------+----------+----------+----------------------+---------------+-----------------------+---------------------+----+--------------+---------------+------------+-----------------------+------------------------+----+-------------+--------------------+------------------------+-------------------------+-----------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
3 | 2 | | 1 | 3 | 2 | single | _timescaledb_internal | _hyper_2_2_0_3_data | 2 | 2 | 2 | 0 | _timescaledb_internal | _hyper_2_2_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
4 | 2 | 2 | 2 | 4 | 2 | single | _timescaledb_internal | _hyper_2_2_0_4_data | 2 | 2 | 2 | 0 | _timescaledb_internal | _hyper_2_2_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
5 | 2 | 3 | | 5 | 2 | single | _timescaledb_internal | _hyper_2_2_0_5_data | 2 | 2 | 2 | 0 | _timescaledb_internal | _hyper_2_2_0_partition | 2 | public | chunk_closing_test | _timescaledb_internal | _hyper_2 | _timescaledb_internal | _hyper_2_root | 1 | STICKY | time | bigint | single | 10000
|
||||
(3 rows)
|
||||
|
||||
\c single
|
||||
\d+ "testNs".*
|
||||
Index "testNs.1-testNs_device_id_timeCustom_idx"
|
||||
\d+ "one_Partition".*
|
||||
Index "one_Partition.1-one_Partition_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "testNs._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "testNs.10-testNs_timeCustom_series_bool_idx"
|
||||
Index "one_Partition.10-one_Partition_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "testNs.2-testNs_timeCustom_series_0_idx"
|
||||
Index "one_Partition.2-one_Partition_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "testNs.3-testNs_timeCustom_series_1_idx"
|
||||
Index "one_Partition.3-one_Partition_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_1 | double precision | series_1 | plain
|
||||
btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL)
|
||||
|
||||
Index "testNs.4-testNs_timeCustom_series_2_idx"
|
||||
Index "one_Partition.4-one_Partition_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Index "testNs.5-testNs_timeCustom_series_bool_idx"
|
||||
Index "one_Partition.5-one_Partition_timeCustom_series_bool_idx"
|
||||
Column | Type | Definition | Storage
|
||||
-------------+---------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_bool | boolean | series_bool | plain
|
||||
btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL)
|
||||
|
||||
Index "testNs.6-testNs_device_id_timeCustom_idx"
|
||||
Index "one_Partition.6-one_Partition_device_id_timeCustom_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+--------+--------------+----------
|
||||
device_id | text | device_id | extended
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
btree, for table "testNs._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL)
|
||||
|
||||
Index "testNs.7-testNs_timeCustom_series_0_idx"
|
||||
Index "one_Partition.7-one_Partition_timeCustom_series_0_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_0 | double precision | series_0 | plain
|
||||
btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL)
|
||||
|
||||
Index "testNs.8-testNs_timeCustom_series_1_idx"
|
||||
Index "one_Partition.8-one_Partition_timeCustom_series_1_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_1 | double precision | series_1 | plain
|
||||
btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_1 IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_2_data", predicate (series_1 IS NOT NULL)
|
||||
|
||||
Index "testNs.9-testNs_timeCustom_series_2_idx"
|
||||
Index "one_Partition.9-one_Partition_timeCustom_series_2_idx"
|
||||
Column | Type | Definition | Storage
|
||||
------------+------------------+--------------+---------
|
||||
timeCustom | bigint | "timeCustom" | plain
|
||||
series_2 | double precision | series_2 | plain
|
||||
btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL)
|
||||
btree, for table "one_Partition._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL)
|
||||
|
||||
Table "testNs._hyper_1_0_replica"
|
||||
Table "one_Partition._hyper_1_0_replica"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
timeCustom | bigint | not null | plain | |
|
||||
@ -175,10 +133,10 @@ btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL)
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Inherits: "testNs"._hyper_1_root
|
||||
Child tables: "testNs"._hyper_1_1_0_partition
|
||||
Inherits: "one_Partition"._hyper_1_root
|
||||
Child tables: "one_Partition"._hyper_1_1_0_partition
|
||||
|
||||
Table "testNs._hyper_1_1_0_1_data"
|
||||
Table "one_Partition._hyper_1_1_0_1_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
timeCustom | bigint | not null | plain | |
|
||||
@ -188,16 +146,16 @@ Child tables: "testNs"._hyper_1_1_0_partition
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"1-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"2-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"3-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"4-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"5-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"1-one_Partition_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"2-one_Partition_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"3-one_Partition_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"4-one_Partition_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"5-one_Partition_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
Check constraints:
|
||||
"time_range" CHECK ("timeCustom" <= '1257897600000000000'::bigint) NOT VALID
|
||||
Inherits: "testNs"._hyper_1_1_0_partition
|
||||
Inherits: "one_Partition"._hyper_1_1_0_partition
|
||||
|
||||
Table "testNs._hyper_1_1_0_2_data"
|
||||
Table "one_Partition._hyper_1_1_0_2_data"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
timeCustom | bigint | not null | plain | |
|
||||
@ -207,16 +165,16 @@ Inherits: "testNs"._hyper_1_1_0_partition
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Indexes:
|
||||
"10-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"6-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"7-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"8-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"9-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
"10-one_Partition_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL
|
||||
"6-one_Partition_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL
|
||||
"7-one_Partition_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL
|
||||
"8-one_Partition_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL
|
||||
"9-one_Partition_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL
|
||||
Check constraints:
|
||||
"time_range" CHECK ("timeCustom" >= '1257897600000000001'::bigint) NOT VALID
|
||||
Inherits: "testNs"._hyper_1_1_0_partition
|
||||
Inherits: "one_Partition"._hyper_1_1_0_partition
|
||||
|
||||
Table "testNs._hyper_1_1_0_partition"
|
||||
Table "one_Partition._hyper_1_1_0_partition"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
timeCustom | bigint | not null | plain | |
|
||||
@ -225,11 +183,11 @@ Inherits: "testNs"._hyper_1_1_0_partition
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Inherits: "testNs"._hyper_1_0_replica
|
||||
Child tables: "testNs"._hyper_1_1_0_1_data,
|
||||
"testNs"._hyper_1_1_0_2_data
|
||||
Inherits: "one_Partition"._hyper_1_0_replica
|
||||
Child tables: "one_Partition"._hyper_1_1_0_1_data,
|
||||
"one_Partition"._hyper_1_1_0_2_data
|
||||
|
||||
Table "testNs._hyper_1_root"
|
||||
Table "one_Partition._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
timeCustom | bigint | not null | plain | |
|
||||
@ -238,9 +196,9 @@ Child tables: "testNs"._hyper_1_1_0_1_data,
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
Child tables: "testNs"._hyper_1_0_replica
|
||||
Child tables: "one_Partition"._hyper_1_0_replica
|
||||
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "one_Partition";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
||||
|
@ -1,24 +1,18 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."two_Partitions" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -26,50 +20,33 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, device_id);
|
||||
SELECT * FROM create_hypertable('"public"."testNs"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
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);
|
||||
BEGIN;
|
||||
\COPY public."testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'two_Partitions'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
INSERT INTO public."testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c postgres
|
||||
\! pg_dump -h localhost -U postgres -Fc single > dump/single.sql
|
||||
\! dropdb -h localhost -U postgres single
|
||||
\! pg_restore -h localhost -U postgres -d postgres -C dump/single.sql
|
||||
\c single
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "two_Partitions";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
||||
|
@ -1,22 +1,18 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."two_Partitions" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -24,46 +20,28 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, device_id);
|
||||
SELECT * FROM create_hypertable('"public"."testNs"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
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);
|
||||
BEGIN;
|
||||
\COPY public."testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'two_Partitions'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
INSERT INTO public."testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
SELECT * FROM PUBLIC."testNs";
|
||||
SELECT * FROM PUBLIC."two_Partitions";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
||||
@ -78,7 +56,7 @@ SELECT * FROM PUBLIC."testNs";
|
||||
1257894000000000000 | dev20 | 1.5 | 2 | |
|
||||
(10 rows)
|
||||
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs";
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions";
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Append
|
||||
@ -96,9 +74,9 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs";
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
(13 rows)
|
||||
|
||||
\echo "The following queries should NOT scan testNs._hyper_1_1_0_partition"
|
||||
"The following queries should NOT scan testNs._hyper_1_1_0_partition"
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE device_id = 'dev20';
|
||||
\echo "The following queries should NOT scan two_Partitions._hyper_1_1_0_partition"
|
||||
"The following queries should NOT scan two_Partitions._hyper_1_1_0_partition"
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions" WHERE device_id = 'dev20';
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Append
|
||||
@ -112,11 +90,11 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE device_id =
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
Recheck Cond: (_hyper_1_2_0_3_data.device_id = 'dev20'::text)
|
||||
Filter: (_timescaledb_catalog.get_partition_for_key(_hyper_1_2_0_3_data.device_id, 32768) = '28646'::smallint)
|
||||
-> Bitmap Index Scan on "13-testNs_device_id_timeCustom_idx"
|
||||
-> Bitmap Index Scan on "13-two_Partitions_device_id_timeCustom_idx"
|
||||
Index Cond: (_hyper_1_2_0_3_data.device_id = 'dev20'::text)
|
||||
(13 rows)
|
||||
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE device_id = 'dev'||'20';
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions" WHERE device_id = 'dev'||'20';
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Append
|
||||
@ -130,11 +108,11 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE device_id =
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
Recheck Cond: (_hyper_1_2_0_3_data.device_id = 'dev20'::text)
|
||||
Filter: (_timescaledb_catalog.get_partition_for_key(_hyper_1_2_0_3_data.device_id, 32768) = '28646'::smallint)
|
||||
-> Bitmap Index Scan on "13-testNs_device_id_timeCustom_idx"
|
||||
-> Bitmap Index Scan on "13-two_Partitions_device_id_timeCustom_idx"
|
||||
Index Cond: (_hyper_1_2_0_3_data.device_id = 'dev20'::text)
|
||||
(13 rows)
|
||||
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE 'dev'||'20' = device_id;
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions" WHERE 'dev'||'20' = device_id;
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Append
|
||||
@ -148,15 +126,15 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE 'dev'||'20'
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
Recheck Cond: ('dev20'::text = _hyper_1_2_0_3_data.device_id)
|
||||
Filter: (_timescaledb_catalog.get_partition_for_key(_hyper_1_2_0_3_data.device_id, 32768) = '28646'::smallint)
|
||||
-> Bitmap Index Scan on "13-testNs_device_id_timeCustom_idx"
|
||||
-> Bitmap Index Scan on "13-two_Partitions_device_id_timeCustom_idx"
|
||||
Index Cond: ('dev20'::text = _hyper_1_2_0_3_data.device_id)
|
||||
(13 rows)
|
||||
|
||||
--TODO: handle this later?
|
||||
--EXPLAIN (verbose ON, costs off) SELECT * FROM "testNs" WHERE device_id IN ('dev20', 'dev21');
|
||||
--EXPLAIN (verbose ON, costs off) SELECT * FROM "two_Partitions" WHERE device_id IN ('dev20', 'dev21');
|
||||
\echo "The following shows non-aggregated queries with time desc using merge append"
|
||||
"The following shows non-aggregated queries with time desc using merge append"
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."two_Partitions" ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
@ -178,16 +156,16 @@ EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" ORDER BY "timeCusto
|
||||
Sort Key: _hyper_1_2_0_partition."timeCustom" DESC NULLS LAST
|
||||
-> Seq Scan on _timescaledb_internal._hyper_1_2_0_partition
|
||||
Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool
|
||||
-> Index Scan using "6-testNs_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
-> Index Scan using "6-two_Partitions_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
Output: _hyper_1_1_0_1_data."timeCustom", _hyper_1_1_0_1_data.device_id, _hyper_1_1_0_1_data.series_0, _hyper_1_1_0_1_data.series_1, _hyper_1_1_0_1_data.series_2, _hyper_1_1_0_1_data.series_bool
|
||||
-> Index Scan using "12-testNs_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
-> Index Scan using "12-two_Partitions_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
Output: _hyper_1_1_0_2_data."timeCustom", _hyper_1_1_0_2_data.device_id, _hyper_1_1_0_2_data.series_0, _hyper_1_1_0_2_data.series_1, _hyper_1_1_0_2_data.series_2, _hyper_1_1_0_2_data.series_bool
|
||||
-> Index Scan using "18-testNs_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
-> Index Scan using "18-two_Partitions_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
(25 rows)
|
||||
|
||||
--shows that more specific indexes are used if the WHERE clauses "match", uses the series_1 index here.
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" WHERE series_1 IS NOT NULL ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."two_Partitions" WHERE series_1 IS NOT NULL ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
@ -212,16 +190,16 @@ EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" WHERE series_1 IS N
|
||||
-> Seq Scan on _timescaledb_internal._hyper_1_2_0_partition
|
||||
Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool
|
||||
Filter: (_hyper_1_2_0_partition.series_1 IS NOT NULL)
|
||||
-> Index Scan using "3-testNs_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
-> Index Scan using "3-two_Partitions_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
Output: _hyper_1_1_0_1_data."timeCustom", _hyper_1_1_0_1_data.device_id, _hyper_1_1_0_1_data.series_0, _hyper_1_1_0_1_data.series_1, _hyper_1_1_0_1_data.series_2, _hyper_1_1_0_1_data.series_bool
|
||||
-> Index Scan using "9-testNs_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
-> Index Scan using "9-two_Partitions_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
Output: _hyper_1_1_0_2_data."timeCustom", _hyper_1_1_0_2_data.device_id, _hyper_1_1_0_2_data.series_0, _hyper_1_1_0_2_data.series_1, _hyper_1_1_0_2_data.series_2, _hyper_1_1_0_2_data.series_bool
|
||||
-> Index Scan using "15-testNs_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
-> Index Scan using "15-two_Partitions_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
(28 rows)
|
||||
|
||||
--here the "match" is implication series_1 > 1 => series_1 IS NOT NULL
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" WHERE series_1 > 1 ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."two_Partitions" WHERE series_1 > 1 ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
@ -246,21 +224,21 @@ EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" WHERE series_1 > 1
|
||||
-> Seq Scan on _timescaledb_internal._hyper_1_2_0_partition
|
||||
Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool
|
||||
Filter: (_hyper_1_2_0_partition.series_1 > '1'::double precision)
|
||||
-> Index Scan using "3-testNs_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
-> Index Scan using "3-two_Partitions_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
Output: _hyper_1_1_0_1_data."timeCustom", _hyper_1_1_0_1_data.device_id, _hyper_1_1_0_1_data.series_0, _hyper_1_1_0_1_data.series_1, _hyper_1_1_0_1_data.series_2, _hyper_1_1_0_1_data.series_bool
|
||||
Index Cond: (_hyper_1_1_0_1_data.series_1 > '1'::double precision)
|
||||
-> Index Scan using "9-testNs_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
-> Index Scan using "9-two_Partitions_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
Output: _hyper_1_1_0_2_data."timeCustom", _hyper_1_1_0_2_data.device_id, _hyper_1_1_0_2_data.series_0, _hyper_1_1_0_2_data.series_1, _hyper_1_1_0_2_data.series_2, _hyper_1_1_0_2_data.series_bool
|
||||
Index Cond: (_hyper_1_1_0_2_data.series_1 > '1'::double precision)
|
||||
-> Index Scan using "15-testNs_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
-> Index Scan using "15-two_Partitions_timeCustom_series_1_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool
|
||||
Index Cond: (_hyper_1_2_0_3_data.series_1 > '1'::double precision)
|
||||
(31 rows)
|
||||
|
||||
--note that without time transform things work too
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom" t, min(series_0) FROM PUBLIC."testNs" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom" t, min(series_0) FROM PUBLIC."two_Partitions" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
Output: _hyper_1_0_replica."timeCustom", (min(_hyper_1_0_replica.series_0))
|
||||
-> GroupAggregate
|
||||
@ -283,16 +261,16 @@ EXPLAIN (verbose ON, costs off)SELECT "timeCustom" t, min(series_0) FROM PUBLIC.
|
||||
Sort Key: _hyper_1_2_0_partition."timeCustom" DESC NULLS LAST
|
||||
-> Seq Scan on _timescaledb_internal._hyper_1_2_0_partition
|
||||
Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.series_0
|
||||
-> Index Scan using "6-testNs_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
-> Index Scan using "6-two_Partitions_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_1_data
|
||||
Output: _hyper_1_1_0_1_data."timeCustom", _hyper_1_1_0_1_data.series_0
|
||||
-> Index Scan using "12-testNs_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
-> Index Scan using "12-two_Partitions_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_1_0_2_data
|
||||
Output: _hyper_1_1_0_2_data."timeCustom", _hyper_1_1_0_2_data.series_0
|
||||
-> Index Scan using "18-testNs_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
-> Index Scan using "18-two_Partitions_timeCustom_device_id_idx" on _timescaledb_internal._hyper_1_2_0_3_data
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.series_0
|
||||
(28 rows)
|
||||
|
||||
--TODO: time transform doesn't work
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"/10 t, min(series_0) FROM PUBLIC."testNs" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"/10 t, min(series_0) FROM PUBLIC."two_Partitions" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
@ -320,7 +298,7 @@ EXPLAIN (verbose ON, costs off)SELECT "timeCustom"/10 t, min(series_0) FROM PUBL
|
||||
Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.series_0
|
||||
(23 rows)
|
||||
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"%10 t, min(series_0) FROM PUBLIC."testNs" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"%10 t, min(series_0) FROM PUBLIC."two_Partitions" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
@ -368,21 +346,21 @@ EXPLAIN (verbose ON, costs off)SELECT * FROM hyper_1 ORDER BY "time" DESC limit
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
Output: _hyper_3_0_replica."time", _hyper_3_0_replica.series_0, _hyper_3_0_replica.series_1, _hyper_3_0_replica.series_2
|
||||
Output: _hyper_2_0_replica."time", _hyper_2_0_replica.series_0, _hyper_2_0_replica.series_1, _hyper_2_0_replica.series_2
|
||||
-> Merge Append
|
||||
Sort Key: _hyper_3_0_replica."time" DESC
|
||||
Sort Key: _hyper_2_0_replica."time" DESC
|
||||
-> Sort
|
||||
Output: _hyper_3_0_replica."time", _hyper_3_0_replica.series_0, _hyper_3_0_replica.series_1, _hyper_3_0_replica.series_2
|
||||
Sort Key: _hyper_3_0_replica."time" DESC
|
||||
-> Seq Scan on _timescaledb_internal._hyper_3_0_replica
|
||||
Output: _hyper_3_0_replica."time", _hyper_3_0_replica.series_0, _hyper_3_0_replica.series_1, _hyper_3_0_replica.series_2
|
||||
Output: _hyper_2_0_replica."time", _hyper_2_0_replica.series_0, _hyper_2_0_replica.series_1, _hyper_2_0_replica.series_2
|
||||
Sort Key: _hyper_2_0_replica."time" DESC
|
||||
-> Seq Scan on _timescaledb_internal._hyper_2_0_replica
|
||||
Output: _hyper_2_0_replica."time", _hyper_2_0_replica.series_0, _hyper_2_0_replica.series_1, _hyper_2_0_replica.series_2
|
||||
-> Sort
|
||||
Output: _hyper_3_5_0_partition."time", _hyper_3_5_0_partition.series_0, _hyper_3_5_0_partition.series_1, _hyper_3_5_0_partition.series_2
|
||||
Sort Key: _hyper_3_5_0_partition."time" DESC
|
||||
-> Seq Scan on _timescaledb_internal._hyper_3_5_0_partition
|
||||
Output: _hyper_3_5_0_partition."time", _hyper_3_5_0_partition.series_0, _hyper_3_5_0_partition.series_1, _hyper_3_5_0_partition.series_2
|
||||
-> Index Scan using "19-hyper_1_time_series_0_idx" on _timescaledb_internal._hyper_3_5_0_7_data
|
||||
Output: _hyper_3_5_0_7_data."time", _hyper_3_5_0_7_data.series_0, _hyper_3_5_0_7_data.series_1, _hyper_3_5_0_7_data.series_2
|
||||
Output: _hyper_2_3_0_partition."time", _hyper_2_3_0_partition.series_0, _hyper_2_3_0_partition.series_1, _hyper_2_3_0_partition.series_2
|
||||
Sort Key: _hyper_2_3_0_partition."time" DESC
|
||||
-> Seq Scan on _timescaledb_internal._hyper_2_3_0_partition
|
||||
Output: _hyper_2_3_0_partition."time", _hyper_2_3_0_partition.series_0, _hyper_2_3_0_partition.series_1, _hyper_2_3_0_partition.series_2
|
||||
-> Index Scan using "19-hyper_1_time_series_0_idx" on _timescaledb_internal._hyper_2_3_0_4_data
|
||||
Output: _hyper_2_3_0_4_data."time", _hyper_2_3_0_4_data.series_0, _hyper_2_3_0_4_data.series_1, _hyper_2_3_0_4_data.series_2
|
||||
(16 rows)
|
||||
|
||||
--TODO: aggregated with date_trunc doesn't work
|
||||
@ -390,21 +368,21 @@ EXPLAIN (verbose ON, costs off)SELECT date_trunc('minute', time) t, min(series_0
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
Output: (date_trunc('minute'::text, _hyper_3_0_replica."time")), (min(_hyper_3_0_replica.series_0))
|
||||
Output: (date_trunc('minute'::text, _hyper_2_0_replica."time")), (min(_hyper_2_0_replica.series_0))
|
||||
-> Sort
|
||||
Output: (date_trunc('minute'::text, _hyper_3_0_replica."time")), (min(_hyper_3_0_replica.series_0))
|
||||
Sort Key: (date_trunc('minute'::text, _hyper_3_0_replica."time")) DESC
|
||||
Output: (date_trunc('minute'::text, _hyper_2_0_replica."time")), (min(_hyper_2_0_replica.series_0))
|
||||
Sort Key: (date_trunc('minute'::text, _hyper_2_0_replica."time")) DESC
|
||||
-> HashAggregate
|
||||
Output: (date_trunc('minute'::text, _hyper_3_0_replica."time")), min(_hyper_3_0_replica.series_0)
|
||||
Group Key: date_trunc('minute'::text, _hyper_3_0_replica."time")
|
||||
Output: (date_trunc('minute'::text, _hyper_2_0_replica."time")), min(_hyper_2_0_replica.series_0)
|
||||
Group Key: date_trunc('minute'::text, _hyper_2_0_replica."time")
|
||||
-> Result
|
||||
Output: date_trunc('minute'::text, _hyper_3_0_replica."time"), _hyper_3_0_replica.series_0
|
||||
Output: date_trunc('minute'::text, _hyper_2_0_replica."time"), _hyper_2_0_replica.series_0
|
||||
-> Append
|
||||
-> Seq Scan on _timescaledb_internal._hyper_3_0_replica
|
||||
Output: _hyper_3_0_replica."time", _hyper_3_0_replica.series_0
|
||||
-> Seq Scan on _timescaledb_internal._hyper_3_5_0_partition
|
||||
Output: _hyper_3_5_0_partition."time", _hyper_3_5_0_partition.series_0
|
||||
-> Seq Scan on _timescaledb_internal._hyper_3_5_0_7_data
|
||||
Output: _hyper_3_5_0_7_data."time", _hyper_3_5_0_7_data.series_0
|
||||
-> Seq Scan on _timescaledb_internal._hyper_2_0_replica
|
||||
Output: _hyper_2_0_replica."time", _hyper_2_0_replica.series_0
|
||||
-> Seq Scan on _timescaledb_internal._hyper_2_3_0_partition
|
||||
Output: _hyper_2_3_0_partition."time", _hyper_2_3_0_partition.series_0
|
||||
-> Seq Scan on _timescaledb_internal._hyper_2_3_0_4_data
|
||||
Output: _hyper_2_3_0_4_data."time", _hyper_2_3_0_4_data.series_0
|
||||
(17 rows)
|
||||
|
||||
|
@ -1,30 +1,23 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set SHOW_CONTEXT never
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY verbose
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
\set ON_ERROR_STOP 0
|
||||
SET client_min_messages = ERROR;
|
||||
drop tablespace if exists tspace1;
|
||||
SET client_min_messages = NOTICE;
|
||||
\set VERBOSITY verbose
|
||||
--test hypertable with tables space
|
||||
create tablespace tspace1 location :TEST_TABLESPACE_PATH;
|
||||
create table test_tspace(time timestamp, temp float, device_id text) tablespace tspace1;
|
||||
@ -115,12 +108,6 @@ Child tables: _timescaledb_internal._hyper_1_2_0_2_data
|
||||
Child tables: _timescaledb_internal._hyper_1_0_replica
|
||||
|
||||
--cleanup
|
||||
\set VERBOSITY default
|
||||
drop table test_tspace;
|
||||
NOTICE: drop cascades to 5 other objects
|
||||
DETAIL: drop cascades to table _timescaledb_internal._hyper_1_0_replica
|
||||
drop cascades to table _timescaledb_internal._hyper_1_1_0_partition
|
||||
drop cascades to table _timescaledb_internal._hyper_1_1_0_1_data
|
||||
drop cascades to table _timescaledb_internal._hyper_1_2_0_partition
|
||||
drop cascades to table _timescaledb_internal._hyper_1_2_0_2_data
|
||||
drop tablespace tspace1;
|
||||
|
@ -1,21 +1,16 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
-- Utility function for grouping/slotting time with a given interval.
|
||||
CREATE OR REPLACE FUNCTION date_group(
|
||||
field timestamp,
|
||||
|
@ -1,23 +1,18 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\o /dev/null
|
||||
\ir include/insert_single.sql
|
||||
\set ON_ERROR_STOP 1
|
||||
\ir create_single_db.sql
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:8: NOTICE: installing required extension "hstore"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "hstore"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
\c single
|
||||
\set ECHO ALL
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."one_Partition" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -25,45 +20,27 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', associated_schema_name=>'testNs' );
|
||||
CREATE INDEX ON PUBLIC."one_Partition" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM create_hypertable('"public"."one_Partition"', 'timeCustom', associated_schema_name=>'one_Partition' );
|
||||
BEGIN;
|
||||
\COPY "testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY "one_Partition" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'one_Partition'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "one_Partition";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 1 | 2 | t
|
||||
@ -78,9 +55,9 @@ SELECT * FROM "testNs";
|
||||
1257987600000000000 | dev1 | 1.5 | 2 | |
|
||||
(10 rows)
|
||||
|
||||
UPDATE "testNs" SET series_1 = 47;
|
||||
UPDATE "testNs" SET series_bool = true;
|
||||
SELECT * FROM "testNs";
|
||||
UPDATE "one_Partition" SET series_1 = 47;
|
||||
UPDATE "one_Partition" SET series_bool = true;
|
||||
SELECT * FROM "one_Partition";
|
||||
timeCustom | device_id | series_0 | series_1 | series_2 | series_bool
|
||||
---------------------+-----------+----------+----------+----------+-------------
|
||||
1257894000000000000 | dev1 | 1.5 | 47 | 2 | t
|
||||
|
@ -13,4 +13,4 @@ PG_PROC_USER=$(ps u | awk '/postgres/ { print $1; exit }')
|
||||
mkdir -p ${TEST_TABLESPACE_PATH}
|
||||
mkdir -p dump
|
||||
|
||||
exec ${PSQL} -v ON_ERROR_STOP=1 -v TEST_TABLESPACE_PATH=\'${TEST_TABLESPACE_PATH}\' $@
|
||||
exec ${PSQL} -v ON_ERROR_STOP=1 -v VERBOSITY=terse -v ECHO=all -v TEST_TABLESPACE_PATH=\'${TEST_TABLESPACE_PATH}\' $@
|
||||
|
@ -1,12 +1,5 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
|
||||
\set ECHO ALL
|
||||
\ir include/insert_single.sql
|
||||
|
||||
\set VERBOSITY default
|
||||
DO $$
|
||||
BEGIN
|
||||
CREATE ROLE alt_usr LOGIN;
|
||||
@ -19,9 +12,8 @@ END$$;
|
||||
\dt
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT * FROM chunk_closing_test;
|
||||
--todo fix error message here:
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "one_Partition";
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
CREATE TABLE "1dim"(time timestamp, temp float);
|
||||
|
22
test/sql/create_chunks.sql
Normal file
22
test/sql/create_chunks.sql
Normal file
@ -0,0 +1,22 @@
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM ONLY chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
create schema test_schema;
|
||||
create table test_schema.test_table(time bigint, temp float8, device_id text);
|
||||
\dt "test_schema".*
|
||||
|
@ -1,12 +1,6 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
|
||||
\ir include/ddl_ops_1.sql
|
||||
|
||||
|
@ -1,13 +1,6 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
-- Expect error when adding user again
|
||||
\set ON_ERROR_STOP 0
|
||||
|
@ -1,14 +1,6 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
\ir include/ddl_ops_1.sql
|
||||
|
||||
SELECT * FROM PUBLIC."Hypertable_1";
|
||||
|
@ -1,14 +1,10 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "two_Partitions";
|
||||
|
||||
DELETE FROM "testNs" WHERE series_0 = 1.5;
|
||||
DELETE FROM "testNs" WHERE series_0 = 100;
|
||||
SELECT * FROM "testNs";
|
||||
DELETE FROM "two_Partitions" WHERE series_0 = 1.5;
|
||||
DELETE FROM "two_Partitions" WHERE series_0 = 100;
|
||||
SELECT * FROM "two_Partitions";
|
||||
|
||||
|
@ -1,14 +1,7 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
|
||||
\c single
|
||||
CREATE TABLE PUBLIC.drop_chunk_test1(time bigint, temp float8, device_id text);
|
||||
CREATE TABLE PUBLIC.drop_chunk_test2(time bigint, temp float8, device_id text);
|
||||
SELECT create_hypertable('public.drop_chunk_test1', 'time', chunk_size_bytes => 10000);
|
||||
|
@ -1,13 +1,6 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
\o
|
||||
\set ECHO ALL
|
||||
|
||||
\c single
|
||||
|
||||
CREATE TABLE drop_test(time timestamp, temp float8, device text);
|
||||
|
||||
@ -16,7 +9,6 @@ SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
INSERT INTO drop_test VALUES('Mon Mar 20 09:17:00.936242 2017', 23.4, 'dev1');
|
||||
SELECT * FROM drop_test;
|
||||
|
||||
-- Drop the extension
|
||||
DROP EXTENSION timescaledb CASCADE;
|
||||
|
||||
-- Querying the original table should not return any rows since all of
|
||||
|
@ -1,19 +1,13 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
\o
|
||||
\set ECHO ALL
|
||||
|
||||
\c single
|
||||
\d+ "_timescaledb_internal".*
|
||||
|
||||
-- Test that renaming hypertable is blocked
|
||||
\set VERBOSITY default
|
||||
\set ON_ERROR_STOP 0
|
||||
ALTER TABLE "testNs" RENAME TO "newname";
|
||||
ALTER TABLE "two_Partitions" RENAME TO "newname";
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
-- Test that renaming ordinary table works
|
||||
@ -22,7 +16,7 @@ ALTER TABLE "renametable" RENAME TO "newname";
|
||||
SELECT * FROM "newname";
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
DROP TABLE "testNs";
|
||||
DROP TABLE "two_Partitions";
|
||||
|
||||
SELECT * FROM _timescaledb_catalog.hypertable;
|
||||
\dt "public".*
|
||||
|
@ -1,4 +1,3 @@
|
||||
\set VERBOSITY default
|
||||
SET client_min_messages = WARNING;
|
||||
DROP DATABASE IF EXISTS single;
|
||||
SET client_min_messages = NOTICE;
|
||||
@ -7,4 +6,3 @@ CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\set VERBOSITY verbose
|
||||
|
@ -1,12 +1,8 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\ir create_single_db.sql
|
||||
|
||||
\c single
|
||||
|
||||
\set ECHO ALL
|
||||
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."one_Partition" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -14,46 +10,27 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."one_Partition" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
|
||||
SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', associated_schema_name=>'testNs' );
|
||||
SELECT * FROM create_hypertable('"public"."one_Partition"', 'timeCustom', associated_schema_name=>'one_Partition' );
|
||||
|
||||
BEGIN;
|
||||
\COPY "testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY "one_Partition" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'one_Partition'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
|
||||
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
|
@ -1,10 +1,8 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\ir create_single_db.sql
|
||||
|
||||
\c single
|
||||
|
||||
CREATE TABLE PUBLIC."testNs" (
|
||||
CREATE TABLE PUBLIC."two_Partitions" (
|
||||
"timeCustom" BIGINT NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
series_0 DOUBLE PRECISION NULL,
|
||||
@ -12,46 +10,28 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_2 DOUBLE PRECISION NULL,
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, device_id);
|
||||
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"."testNs"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
SELECT * FROM create_hypertable('"public"."two_Partitions"'::regclass, 'timeCustom'::name, 'device_id'::name, associated_schema_name=>'_timescaledb_internal'::text, number_partitions => 2);
|
||||
|
||||
BEGIN;
|
||||
\COPY public."testNs" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
\COPY public."two_Partitions" FROM 'data/ds1_dev1_1.tsv' NULL AS '';
|
||||
COMMIT;
|
||||
|
||||
SELECT _timescaledb_meta_api.close_chunk_end_immediate(c.id)
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'testNs'), 'dev1') part
|
||||
FROM get_open_partition_for_key((SELECT id FROM _timescaledb_catalog.hypertable WHERE table_name = 'two_Partitions'), 'dev1') part
|
||||
INNER JOIN _timescaledb_catalog.chunk c ON (c.partition_id = part.id);
|
||||
|
||||
INSERT INTO public."testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257987600000000000, 'dev1', 1.5, 1),
|
||||
(1257987600000000000, 'dev1', 1.5, 2),
|
||||
(1257894000000000000, 'dev20', 1.5, 1),
|
||||
(1257894002000000000, 'dev1', 2.5, 3);
|
||||
|
||||
INSERT INTO "testNs"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
INSERT INTO "two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
||||
(1257894000000000000, 'dev20', 1.5, 2);
|
||||
|
||||
CREATE TABLE chunk_closing_test(
|
||||
time BIGINT,
|
||||
metric INTEGER,
|
||||
device_id TEXT
|
||||
);
|
||||
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', 2, chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM _timescaledb_catalog.chunk c
|
||||
LEFT JOIN _timescaledb_catalog.chunk_replica_node crn ON (c.id = crn.chunk_id)
|
||||
LEFT JOIN _timescaledb_catalog.partition_replica pr ON (crn.partition_replica_id = pr.id)
|
||||
LEFT JOIN _timescaledb_catalog.hypertable h ON (pr.hypertable_id = h.id)
|
||||
WHERE h.schema_name = 'public' AND h.table_name = 'chunk_closing_test';
|
||||
|
@ -1,6 +1,3 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\set ECHO ALL
|
||||
\ir include/insert_two_partitions.sql
|
||||
|
||||
\d+ "_timescaledb_internal".*
|
||||
@ -9,16 +6,14 @@ FROM "_timescaledb_internal"._hyper_1_0_replica;
|
||||
SELECT * FROM _timescaledb_catalog.chunk;
|
||||
SELECT * FROM _timescaledb_catalog.chunk_replica_node;
|
||||
SELECT * FROM _timescaledb_catalog.partition_replica;
|
||||
SELECT * FROM chunk_closing_test;
|
||||
SELECT * FROM ONLY chunk_closing_test;
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM ONLY "testNs";
|
||||
SELECT * FROM "two_Partitions";
|
||||
SELECT * FROM ONLY "two_Partitions";
|
||||
|
||||
|
||||
CREATE TABLE error_test(time timestamp, temp float8, device text NOT NULL);
|
||||
SELECT create_hypertable('error_test', 'time', 'device', 2);
|
||||
|
||||
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:20.1 2017', 21.3, 'dev1');
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
-- generate insert error
|
||||
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:22.3 2017', 21.1, NULL);
|
||||
|
@ -1,11 +1,7 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\set ECHO ALL
|
||||
\ir include/insert_single.sql
|
||||
|
||||
\c single
|
||||
\d+ "testNs".*
|
||||
SELECT * FROM "testNs";
|
||||
\d+ "one_Partition".*
|
||||
SELECT * FROM "one_Partition";
|
||||
|
||||
--test that we can insert data into a 1-dimensional table (only time partitioning)
|
||||
CREATE TABLE "1dim"(time timestamp, temp float);
|
||||
|
@ -1,14 +1,7 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\set VERBOSITY verbose
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
\o
|
||||
|
||||
\set ECHO ALL
|
||||
|
||||
|
||||
\c postgres
|
||||
|
||||
\! pg_dump -h localhost -U postgres -Fc single > dump/single.sql
|
||||
@ -17,7 +10,7 @@
|
||||
\! pg_restore -h localhost -U postgres -d postgres -C dump/single.sql
|
||||
|
||||
\c single
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "two_Partitions";
|
||||
|
||||
--query for the extension tables/sequences that will not be dumped by pg_dump (should be empty)
|
||||
SELECT objid::regclass, *
|
||||
|
@ -1,38 +1,33 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\o /dev/null
|
||||
\ir include/insert_two_partitions.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
SELECT * FROM PUBLIC."testNs";
|
||||
SELECT * FROM PUBLIC."two_Partitions";
|
||||
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs";
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions";
|
||||
|
||||
\echo "The following queries should NOT scan testNs._hyper_1_1_0_partition"
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE device_id = 'dev20';
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE device_id = 'dev'||'20';
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."testNs" WHERE 'dev'||'20' = device_id;
|
||||
\echo "The following queries should NOT scan two_Partitions._hyper_1_1_0_partition"
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions" WHERE device_id = 'dev20';
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions" WHERE device_id = 'dev'||'20';
|
||||
EXPLAIN (verbose ON, costs off) SELECT * FROM PUBLIC."two_Partitions" WHERE 'dev'||'20' = device_id;
|
||||
|
||||
--TODO: handle this later?
|
||||
--EXPLAIN (verbose ON, costs off) SELECT * FROM "testNs" WHERE device_id IN ('dev20', 'dev21');
|
||||
--EXPLAIN (verbose ON, costs off) SELECT * FROM "two_Partitions" WHERE device_id IN ('dev20', 'dev21');
|
||||
|
||||
\echo "The following shows non-aggregated queries with time desc using merge append"
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."two_Partitions" ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
|
||||
--shows that more specific indexes are used if the WHERE clauses "match", uses the series_1 index here.
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" WHERE series_1 IS NOT NULL ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."two_Partitions" WHERE series_1 IS NOT NULL ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
--here the "match" is implication series_1 > 1 => series_1 IS NOT NULL
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."testNs" WHERE series_1 > 1 ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT * FROM PUBLIC."two_Partitions" WHERE series_1 > 1 ORDER BY "timeCustom" DESC NULLS LAST limit 2;
|
||||
|
||||
--note that without time transform things work too
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom" t, min(series_0) FROM PUBLIC."testNs" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom" t, min(series_0) FROM PUBLIC."two_Partitions" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
|
||||
--TODO: time transform doesn't work
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"/10 t, min(series_0) FROM PUBLIC."testNs" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"%10 t, min(series_0) FROM PUBLIC."testNs" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"/10 t, min(series_0) FROM PUBLIC."two_Partitions" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
EXPLAIN (verbose ON, costs off)SELECT "timeCustom"%10 t, min(series_0) FROM PUBLIC."two_Partitions" GROUP BY t ORDER BY t DESC NULLS LAST limit 2;
|
||||
|
||||
|
||||
--make table with timestamp. Test timestamp instead of int time.
|
||||
|
@ -1,20 +1,10 @@
|
||||
|
||||
\set ON_ERROR_STOP 1
|
||||
\set SHOW_CONTEXT never
|
||||
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
|
||||
SET client_min_messages = ERROR;
|
||||
drop tablespace if exists tspace1;
|
||||
SET client_min_messages = NOTICE;
|
||||
|
||||
\set VERBOSITY verbose
|
||||
|
||||
--test hypertable with tables space
|
||||
create tablespace tspace1 location :TEST_TABLESPACE_PATH;
|
||||
create table test_tspace(time timestamp, temp float, device_id text) tablespace tspace1;
|
||||
@ -28,6 +18,5 @@ insert into test_tspace values ('2017-01-20T09:00:02', 22.3, 'dev7');
|
||||
\d+ _timescaledb_internal.*
|
||||
|
||||
--cleanup
|
||||
\set VERBOSITY default
|
||||
drop table test_tspace;
|
||||
drop tablespace tspace1;
|
||||
|
@ -1,11 +1,6 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\o /dev/null
|
||||
\ir include/create_single_db.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
-- Utility function for grouping/slotting time with a given interval.
|
||||
CREATE OR REPLACE FUNCTION date_group(
|
||||
|
@ -1,15 +1,10 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\o /dev/null
|
||||
\ir include/insert_single.sql
|
||||
|
||||
\o
|
||||
\set ECHO ALL
|
||||
\c single
|
||||
|
||||
SELECT * FROM "testNs";
|
||||
SELECT * FROM "one_Partition";
|
||||
|
||||
UPDATE "testNs" SET series_1 = 47;
|
||||
UPDATE "testNs" SET series_bool = true;
|
||||
SELECT * FROM "testNs";
|
||||
UPDATE "one_Partition" SET series_1 = 47;
|
||||
UPDATE "one_Partition" SET series_bool = true;
|
||||
SELECT * FROM "one_Partition";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user