mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-19 20:24:46 +08:00
Update hypertable metadata table to include 'insert_temp_table' and keep the insert temp table in-sync with root in terms of fields.
This commit is contained in:
parent
ee36949beb
commit
ff7762ea9e
@ -40,6 +40,7 @@ CREATE TABLE IF NOT EXISTS hypertable (
|
||||
root_table_name NAME NOT NULL,
|
||||
distinct_schema_name NAME NOT NULL,
|
||||
distinct_table_name NAME NOT NULL,
|
||||
insert_temp_table_name NAME NOT NULL,
|
||||
replication_factor SMALLINT NOT NULL CHECK (replication_factor > 0),
|
||||
placement chunk_placement_type NOT NULL,
|
||||
time_field_name NAME NOT NULL,
|
||||
|
@ -7,6 +7,7 @@ CREATE OR REPLACE FUNCTION add_hypertable(
|
||||
number_partitions SMALLINT = NULL,
|
||||
associated_schema_name NAME = NULL,
|
||||
associated_table_prefix NAME = NULL,
|
||||
insert_temp_table_name NAME = NULL,
|
||||
hypertable_name NAME = NULL,
|
||||
placement chunk_placement_type = 'STICKY'
|
||||
)
|
||||
@ -36,7 +37,7 @@ BEGIN
|
||||
INTO hypertable_row
|
||||
FROM dblink(
|
||||
'meta_conn',
|
||||
format('SELECT t FROM _meta.add_hypertable(%L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L) t ',
|
||||
format('SELECT t FROM _meta.add_hypertable(%L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L) t ',
|
||||
schema_name,
|
||||
table_name,
|
||||
time_field_name,
|
||||
@ -46,6 +47,7 @@ BEGIN
|
||||
number_partitions,
|
||||
associated_schema_name,
|
||||
associated_table_prefix,
|
||||
insert_temp_table_name,
|
||||
hypertable_name,
|
||||
placement,
|
||||
current_database()
|
||||
|
@ -20,6 +20,8 @@ BEGIN
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
-- Used to update a hypertable (or the insert temp table) when a new
|
||||
-- field is added.
|
||||
CREATE OR REPLACE FUNCTION _sysinternal.create_field_on_table(
|
||||
schema_name NAME,
|
||||
table_name NAME,
|
||||
@ -209,14 +211,20 @@ BEGIN
|
||||
FROM hypertable AS h
|
||||
WHERE h.name = NEW.hypertable_name;
|
||||
|
||||
-- update root table
|
||||
PERFORM _sysinternal.create_field_on_table(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||
NEW.name, NEW.attnum, NEW.data_type, NEW.default_value, NEW.not_null);
|
||||
IF new.created_on <> current_database() THEN
|
||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
||||
PERFORM _sysinternal.create_field_on_table(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||
-- update insert temp table
|
||||
PERFORM _sysinternal.create_field_on_table(hypertable_row.associated_schema_name, hypertable_row.insert_temp_table_name,
|
||||
NEW.name, NEW.attnum, NEW.data_type, NEW.default_value, NEW.not_null);
|
||||
|
||||
IF new.created_on <> current_database() THEN
|
||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
||||
-- update main table on others
|
||||
PERFORM _sysinternal.create_field_on_table(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||
NEW.name, NEW.attnum, NEW.data_type, NEW.default_value, NEW.not_null);
|
||||
END IF;
|
||||
|
||||
PERFORM _sysinternal.create_partition_constraint_for_field(NEW.hypertable_name, NEW.name);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'UPDATE' THEN
|
||||
@ -227,30 +235,46 @@ BEGIN
|
||||
|
||||
IF NEW.default_value IS DISTINCT FROM OLD.default_value THEN
|
||||
update_found = TRUE;
|
||||
-- update root table
|
||||
PERFORM _sysinternal.exec_alter_column_set_default(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||
NEW.name, NEW.default_value);
|
||||
-- update insert temp table
|
||||
PERFORM _sysinternal.exec_alter_column_set_default(hypertable_row.associated_schema_name, hypertable_row.insert_temp_table_name,
|
||||
NEW.name, NEW.default_value);
|
||||
|
||||
IF NEW.modified_on <> current_database() THEN
|
||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
||||
-- update main table on others
|
||||
PERFORM _sysinternal.exec_alter_column_set_default(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||
NEW.name, NEW.default_value);
|
||||
END IF;
|
||||
END IF;
|
||||
IF NEW.not_null IS DISTINCT FROM OLD.not_null THEN
|
||||
update_found = TRUE;
|
||||
-- update root table
|
||||
PERFORM _sysinternal.exec_alter_column_set_not_null(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||
NEW.name, NEW.not_null);
|
||||
-- update insert temp table
|
||||
PERFORM _sysinternal.exec_alter_column_set_not_null(hypertable_row.associated_schema_name, hypertable_row.insert_temp_table_name,
|
||||
NEW.name, NEW.not_null);
|
||||
IF NEW.modified_on <> current_database() THEN
|
||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
||||
-- update main table on others
|
||||
PERFORM _sysinternal.exec_alter_column_set_not_null(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||
NEW.name, NEW.not_null);
|
||||
END IF;
|
||||
END IF;
|
||||
IF NEW.name IS DISTINCT FROM OLD.name THEN
|
||||
update_found = TRUE;
|
||||
-- update root table
|
||||
PERFORM _sysinternal.exec_alter_table_rename_column(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||
OLD.name, NEW.name);
|
||||
-- update insert temp table
|
||||
PERFORM _sysinternal.exec_alter_table_rename_column(hypertable_row.associated_schema_name, hypertable_row.insert_temp_table_name,
|
||||
OLD.name, NEW.name);
|
||||
IF NEW.modified_on <> current_database() THEN
|
||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
||||
-- update main table on others
|
||||
PERFORM _sysinternal.exec_alter_table_rename_column(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||
OLD.name, NEW.name);
|
||||
END IF;
|
||||
@ -294,10 +318,16 @@ BEGIN
|
||||
FROM hypertable AS h
|
||||
WHERE h.name = NEW.hypertable_name;
|
||||
|
||||
-- update root table
|
||||
PERFORM _sysinternal.drop_field_on_table(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||
NEW.name);
|
||||
-- update insert temp table
|
||||
PERFORM _sysinternal.drop_field_on_table(hypertable_row.associated_schema_name, hypertable_row.insert_temp_table_name,
|
||||
NEW.name);
|
||||
|
||||
IF NEW.deleted_on <> current_database() THEN
|
||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
||||
-- update main table on others
|
||||
PERFORM _sysinternal.drop_field_on_table(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||
NEW.name);
|
||||
END IF;
|
||||
@ -306,4 +336,3 @@ BEGIN
|
||||
END
|
||||
$BODY$
|
||||
SET SEARCH_PATH = 'public';
|
||||
|
||||
|
@ -16,6 +16,7 @@ BEGIN
|
||||
|
||||
PERFORM _sysinternal.create_root_table(NEW.root_schema_name, NEW.root_table_name);
|
||||
PERFORM _sysinternal.create_root_distinct_table(NEW.distinct_schema_name, NEW.distinct_table_name);
|
||||
PERFORM _sysinternal.create_insert_temp_table(NEW.associated_schema_name, NEW.insert_temp_table_name);
|
||||
|
||||
IF NEW.created_on <> current_database() THEN
|
||||
PERFORM _sysinternal.create_main_table(NEW.main_schema_name, NEW.main_table_name);
|
||||
|
@ -41,6 +41,25 @@ BEGIN
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
-- Creates the temporary table for INSERTs. INSERTs on the root table are
|
||||
-- redirected to the temporary table using a RULE. An associated trigger
|
||||
-- on this table then inserts all rows in bulk after all rows are INSERTed.
|
||||
-- The table is UNLOGGED for performance.
|
||||
CREATE OR REPLACE FUNCTION _sysinternal.create_insert_temp_table(
|
||||
schema_name NAME,
|
||||
table_name NAME
|
||||
)
|
||||
RETURNS VOID LANGUAGE PLPGSQL VOLATILE AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
EXECUTE format(
|
||||
$$
|
||||
CREATE UNLOGGED TABLE IF NOT EXISTS %I.%I (
|
||||
)
|
||||
$$, schema_name, table_name);
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION _sysinternal.create_root_distinct_table(
|
||||
schema_name NAME,
|
||||
table_name NAME
|
||||
@ -244,5 +263,3 @@ BEGIN
|
||||
END IF;
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
|
||||
|
@ -54,7 +54,6 @@ BEGIN
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION add_partition_epoch(
|
||||
hypertable_name NAME,
|
||||
keyspace_start SMALLINT [],
|
||||
@ -90,5 +89,3 @@ SELECT add_partition_epoch(
|
||||
partitioning_field
|
||||
)
|
||||
$BODY$;
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@ CREATE OR REPLACE FUNCTION _meta.add_hypertable(
|
||||
number_partitions SMALLINT,
|
||||
associated_schema_name NAME,
|
||||
associated_table_prefix NAME,
|
||||
insert_temp_table_name NAME,
|
||||
hypertable_name NAME,
|
||||
placement chunk_placement_type,
|
||||
created_on NAME
|
||||
@ -34,6 +35,10 @@ BEGIN
|
||||
associated_table_prefix = format('_hyper_%s', id);
|
||||
END IF;
|
||||
|
||||
IF insert_temp_table_name IS NULL THEN
|
||||
insert_temp_table_name = format('_hyper_%s_insert_temp', id);
|
||||
END IF;
|
||||
|
||||
IF number_partitions IS NULL THEN
|
||||
SELECT COUNT(*)
|
||||
INTO number_partitions
|
||||
@ -50,6 +55,7 @@ BEGIN
|
||||
associated_schema_name, associated_table_prefix,
|
||||
root_schema_name, root_table_name,
|
||||
distinct_schema_name, distinct_table_name,
|
||||
insert_temp_table_name,
|
||||
replication_factor,
|
||||
placement,
|
||||
time_field_name, time_field_type,
|
||||
@ -60,6 +66,7 @@ BEGIN
|
||||
associated_schema_name, associated_table_prefix,
|
||||
associated_schema_name, format('%s_root', associated_table_prefix),
|
||||
associated_schema_name, format('%s_distinct', associated_table_prefix),
|
||||
insert_temp_table_name,
|
||||
replication_factor,
|
||||
placement,
|
||||
time_field_name, time_field_type,
|
||||
@ -190,4 +197,3 @@ SELECT set_config('io.deleting_node', modified_on, true);
|
||||
DELETE FROM hypertable_index i
|
||||
WHERE i.main_index_name = drop_index.main_index_name AND i.main_schema_name = drop_index.main_schema_name;
|
||||
$BODY$;
|
||||
|
||||
|
@ -52,9 +52,9 @@ CREATE INDEX ON PUBLIC."testNs" (temp, time DESC NULLS LAST) WHERE temp IS NOT N
|
||||
CREATE INDEX ON PUBLIC."testNs" (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on, time DESC NULLS LAST) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on IS NOT NULL;
|
||||
SELECT * FROM add_hypertable('"public"."testNs"', 'time', 'Device_id', hypertable_name=>'testNs');
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT set_is_distinct_flag('"public"."testNs"', 'Device_id', TRUE);
|
||||
@ -96,9 +96,9 @@ FROM meta;
|
||||
|
||||
SELECT *
|
||||
FROM hypertable;
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT *
|
||||
@ -200,9 +200,9 @@ FROM meta;
|
||||
|
||||
SELECT *
|
||||
FROM hypertable;
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT *
|
||||
@ -411,6 +411,16 @@ Index "_sys_1_testNs._hyper_1_distinct_pkey"
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "_sys_1_testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "_sys_1_testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
Device_id | text | not null | extended | |
|
||||
temp | double precision | | plain | |
|
||||
occupied | boolean | | plain | |
|
||||
latitude | bigint | | plain | |
|
||||
really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | |
|
||||
|
||||
Table "_sys_1_testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||
@ -563,6 +573,16 @@ Index "_sys_1_testNs._hyper_1_distinct_pkey"
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "_sys_1_testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "_sys_1_testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
Device_id | text | not null | extended | |
|
||||
temp | double precision | | plain | |
|
||||
occupied | boolean | | plain | |
|
||||
latitude | bigint | | plain | |
|
||||
really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | |
|
||||
|
||||
Table "_sys_1_testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||
@ -787,6 +807,16 @@ Index "_sys_1_testNs._hyper_1_distinct_pkey"
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "_sys_1_testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "_sys_1_testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
Device_id | text | not null | extended | |
|
||||
temp | double precision | | plain | |
|
||||
occupied | boolean | | plain | |
|
||||
latitude | bigint | | plain | |
|
||||
really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | |
|
||||
|
||||
Table "_sys_1_testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||
|
@ -51,15 +51,15 @@ CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id");
|
||||
SELECT * FROM add_hypertable('"public"."Hypertable_1"', 'time', 'Device_id');
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
-----------------------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
public."Hypertable_1" | public | Hypertable_1 | _sys_1_ | _hyper_1 | _sys_1_ | _hyper_1_root | _sys_1_ | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
-----------------------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
public."Hypertable_1" | public | Hypertable_1 | _sys_1_ | _hyper_1 | _sys_1_ | _hyper_1_root | _sys_1_ | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM hypertable;
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
-----------------------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
public."Hypertable_1" | public | Hypertable_1 | _sys_1_ | _hyper_1 | _sys_1_ | _hyper_1_root | _sys_1_ | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
-----------------------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
public."Hypertable_1" | public | Hypertable_1 | _sys_1_ | _hyper_1 | _sys_1_ | _hyper_1_root | _sys_1_ | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM hypertable_index;
|
||||
|
@ -53,9 +53,9 @@ CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_1) WHERE series_1
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM add_hypertable('"public"."testNs"', 'time', 'device_id', hypertable_name=>'testNs', associated_schema_name=>'testNs' );
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE);
|
||||
@ -319,6 +319,16 @@ Child tables: "testNs"._hyper_1_0_distinct
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
device_id | text | not null | extended | |
|
||||
series_0 | double precision | | plain | |
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
|
||||
Table "testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
@ -438,6 +448,16 @@ Child tables: "testNs"._hyper_1_0_distinct
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
device_id | text | not null | extended | |
|
||||
series_0 | double precision | | plain | |
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
|
||||
Table "testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
|
@ -53,9 +53,9 @@ CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_1) WHERE series_1
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL;
|
||||
SELECT * FROM add_hypertable('"public"."testNs"', 'time', 'device_id', hypertable_name=>'testNs', associated_schema_name=>'testNs' );
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1
|
||||
name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | insert_temp_table_name | replication_factor | placement | time_field_name | time_field_type | created_on
|
||||
--------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+------------------------+--------------------+-----------+-----------------+-----------------+------------
|
||||
testNs | public | testNs | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | _hyper_1_insert_temp | 1 | STICKY | time | bigint | Test1
|
||||
(1 row)
|
||||
|
||||
SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE);
|
||||
@ -319,6 +319,16 @@ Child tables: "testNs"._hyper_1_0_distinct
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
device_id | text | not null | extended | |
|
||||
series_0 | double precision | | plain | |
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
|
||||
Table "testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
@ -438,6 +448,16 @@ Child tables: "testNs"._hyper_1_0_distinct
|
||||
value | text | value | extended
|
||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
||||
|
||||
Unlogged table "testNs._hyper_1_insert_temp"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
time | bigint | not null | plain | |
|
||||
device_id | text | not null | extended | |
|
||||
series_0 | double precision | | plain | |
|
||||
series_1 | double precision | | plain | |
|
||||
series_2 | double precision | | plain | |
|
||||
series_bool | boolean | | plain | |
|
||||
|
||||
Table "testNs._hyper_1_root"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
-------------+------------------+-----------+----------+--------------+-------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user