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,
|
root_table_name NAME NOT NULL,
|
||||||
distinct_schema_name NAME NOT NULL,
|
distinct_schema_name NAME NOT NULL,
|
||||||
distinct_table_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),
|
replication_factor SMALLINT NOT NULL CHECK (replication_factor > 0),
|
||||||
placement chunk_placement_type NOT NULL,
|
placement chunk_placement_type NOT NULL,
|
||||||
time_field_name NAME NOT NULL,
|
time_field_name NAME NOT NULL,
|
||||||
|
@ -7,6 +7,7 @@ CREATE OR REPLACE FUNCTION add_hypertable(
|
|||||||
number_partitions SMALLINT = NULL,
|
number_partitions SMALLINT = NULL,
|
||||||
associated_schema_name NAME = NULL,
|
associated_schema_name NAME = NULL,
|
||||||
associated_table_prefix NAME = NULL,
|
associated_table_prefix NAME = NULL,
|
||||||
|
insert_temp_table_name NAME = NULL,
|
||||||
hypertable_name NAME = NULL,
|
hypertable_name NAME = NULL,
|
||||||
placement chunk_placement_type = 'STICKY'
|
placement chunk_placement_type = 'STICKY'
|
||||||
)
|
)
|
||||||
@ -36,7 +37,7 @@ BEGIN
|
|||||||
INTO hypertable_row
|
INTO hypertable_row
|
||||||
FROM dblink(
|
FROM dblink(
|
||||||
'meta_conn',
|
'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,
|
schema_name,
|
||||||
table_name,
|
table_name,
|
||||||
time_field_name,
|
time_field_name,
|
||||||
@ -46,6 +47,7 @@ BEGIN
|
|||||||
number_partitions,
|
number_partitions,
|
||||||
associated_schema_name,
|
associated_schema_name,
|
||||||
associated_table_prefix,
|
associated_table_prefix,
|
||||||
|
insert_temp_table_name,
|
||||||
hypertable_name,
|
hypertable_name,
|
||||||
placement,
|
placement,
|
||||||
current_database()
|
current_database()
|
||||||
|
@ -20,6 +20,8 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$BODY$;
|
$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(
|
CREATE OR REPLACE FUNCTION _sysinternal.create_field_on_table(
|
||||||
schema_name NAME,
|
schema_name NAME,
|
||||||
table_name NAME,
|
table_name NAME,
|
||||||
@ -209,14 +211,20 @@ BEGIN
|
|||||||
FROM hypertable AS h
|
FROM hypertable AS h
|
||||||
WHERE h.name = NEW.hypertable_name;
|
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,
|
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);
|
NEW.name, NEW.attnum, NEW.data_type, NEW.default_value, NEW.not_null);
|
||||||
IF new.created_on <> current_database() THEN
|
-- update insert temp table
|
||||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
PERFORM _sysinternal.create_field_on_table(hypertable_row.associated_schema_name, hypertable_row.insert_temp_table_name,
|
||||||
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);
|
NEW.name, NEW.attnum, NEW.data_type, NEW.default_value, NEW.not_null);
|
||||||
|
|
||||||
END IF;
|
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);
|
PERFORM _sysinternal.create_partition_constraint_for_field(NEW.hypertable_name, NEW.name);
|
||||||
RETURN NEW;
|
RETURN NEW;
|
||||||
ELSIF TG_OP = 'UPDATE' THEN
|
ELSIF TG_OP = 'UPDATE' THEN
|
||||||
@ -227,30 +235,46 @@ BEGIN
|
|||||||
|
|
||||||
IF NEW.default_value IS DISTINCT FROM OLD.default_value THEN
|
IF NEW.default_value IS DISTINCT FROM OLD.default_value THEN
|
||||||
update_found = TRUE;
|
update_found = TRUE;
|
||||||
|
-- update root table
|
||||||
PERFORM _sysinternal.exec_alter_column_set_default(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
PERFORM _sysinternal.exec_alter_column_set_default(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||||
NEW.name, NEW.default_value);
|
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
|
IF NEW.modified_on <> current_database() THEN
|
||||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
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,
|
PERFORM _sysinternal.exec_alter_column_set_default(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||||
NEW.name, NEW.default_value);
|
NEW.name, NEW.default_value);
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
IF NEW.not_null IS DISTINCT FROM OLD.not_null THEN
|
IF NEW.not_null IS DISTINCT FROM OLD.not_null THEN
|
||||||
update_found = TRUE;
|
update_found = TRUE;
|
||||||
|
-- update root table
|
||||||
PERFORM _sysinternal.exec_alter_column_set_not_null(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
PERFORM _sysinternal.exec_alter_column_set_not_null(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||||
NEW.name, NEW.not_null);
|
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
|
IF NEW.modified_on <> current_database() THEN
|
||||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
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,
|
PERFORM _sysinternal.exec_alter_column_set_not_null(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||||
NEW.name, NEW.not_null);
|
NEW.name, NEW.not_null);
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
IF NEW.name IS DISTINCT FROM OLD.name THEN
|
IF NEW.name IS DISTINCT FROM OLD.name THEN
|
||||||
update_found = TRUE;
|
update_found = TRUE;
|
||||||
|
-- update root table
|
||||||
PERFORM _sysinternal.exec_alter_table_rename_column(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
PERFORM _sysinternal.exec_alter_table_rename_column(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||||
OLD.name, NEW.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
|
IF NEW.modified_on <> current_database() THEN
|
||||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
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,
|
PERFORM _sysinternal.exec_alter_table_rename_column(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||||
OLD.name, NEW.name);
|
OLD.name, NEW.name);
|
||||||
END IF;
|
END IF;
|
||||||
@ -294,10 +318,16 @@ BEGIN
|
|||||||
FROM hypertable AS h
|
FROM hypertable AS h
|
||||||
WHERE h.name = NEW.hypertable_name;
|
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,
|
PERFORM _sysinternal.drop_field_on_table(hypertable_row.root_schema_name, hypertable_row.root_table_name,
|
||||||
NEW.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
|
IF NEW.deleted_on <> current_database() THEN
|
||||||
PERFORM set_config('io.ignore_ddl_in_trigger', 'true', true);
|
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,
|
PERFORM _sysinternal.drop_field_on_table(hypertable_row.main_schema_name, hypertable_row.main_table_name,
|
||||||
NEW.name);
|
NEW.name);
|
||||||
END IF;
|
END IF;
|
||||||
@ -306,4 +336,3 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$BODY$
|
$BODY$
|
||||||
SET SEARCH_PATH = 'public';
|
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_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_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
|
IF NEW.created_on <> current_database() THEN
|
||||||
PERFORM _sysinternal.create_main_table(NEW.main_schema_name, NEW.main_table_name);
|
PERFORM _sysinternal.create_main_table(NEW.main_schema_name, NEW.main_table_name);
|
||||||
|
@ -41,6 +41,25 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$BODY$;
|
$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(
|
CREATE OR REPLACE FUNCTION _sysinternal.create_root_distinct_table(
|
||||||
schema_name NAME,
|
schema_name NAME,
|
||||||
table_name NAME
|
table_name NAME
|
||||||
@ -244,5 +263,3 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
END
|
END
|
||||||
$BODY$;
|
$BODY$;
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$BODY$;
|
$BODY$;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION add_partition_epoch(
|
CREATE OR REPLACE FUNCTION add_partition_epoch(
|
||||||
hypertable_name NAME,
|
hypertable_name NAME,
|
||||||
keyspace_start SMALLINT [],
|
keyspace_start SMALLINT [],
|
||||||
@ -90,5 +89,3 @@ SELECT add_partition_epoch(
|
|||||||
partitioning_field
|
partitioning_field
|
||||||
)
|
)
|
||||||
$BODY$;
|
$BODY$;
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ CREATE OR REPLACE FUNCTION _meta.add_hypertable(
|
|||||||
number_partitions SMALLINT,
|
number_partitions SMALLINT,
|
||||||
associated_schema_name NAME,
|
associated_schema_name NAME,
|
||||||
associated_table_prefix NAME,
|
associated_table_prefix NAME,
|
||||||
|
insert_temp_table_name NAME,
|
||||||
hypertable_name NAME,
|
hypertable_name NAME,
|
||||||
placement chunk_placement_type,
|
placement chunk_placement_type,
|
||||||
created_on NAME
|
created_on NAME
|
||||||
@ -34,6 +35,10 @@ BEGIN
|
|||||||
associated_table_prefix = format('_hyper_%s', id);
|
associated_table_prefix = format('_hyper_%s', id);
|
||||||
END IF;
|
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
|
IF number_partitions IS NULL THEN
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
INTO number_partitions
|
INTO number_partitions
|
||||||
@ -50,6 +55,7 @@ BEGIN
|
|||||||
associated_schema_name, associated_table_prefix,
|
associated_schema_name, associated_table_prefix,
|
||||||
root_schema_name, root_table_name,
|
root_schema_name, root_table_name,
|
||||||
distinct_schema_name, distinct_table_name,
|
distinct_schema_name, distinct_table_name,
|
||||||
|
insert_temp_table_name,
|
||||||
replication_factor,
|
replication_factor,
|
||||||
placement,
|
placement,
|
||||||
time_field_name, time_field_type,
|
time_field_name, time_field_type,
|
||||||
@ -60,6 +66,7 @@ BEGIN
|
|||||||
associated_schema_name, associated_table_prefix,
|
associated_schema_name, associated_table_prefix,
|
||||||
associated_schema_name, format('%s_root', associated_table_prefix),
|
associated_schema_name, format('%s_root', associated_table_prefix),
|
||||||
associated_schema_name, format('%s_distinct', associated_table_prefix),
|
associated_schema_name, format('%s_distinct', associated_table_prefix),
|
||||||
|
insert_temp_table_name,
|
||||||
replication_factor,
|
replication_factor,
|
||||||
placement,
|
placement,
|
||||||
time_field_name, time_field_type,
|
time_field_name, time_field_type,
|
||||||
@ -190,4 +197,3 @@ SELECT set_config('io.deleting_node', modified_on, true);
|
|||||||
DELETE FROM hypertable_index i
|
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;
|
WHERE i.main_index_name = drop_index.main_index_name AND i.main_schema_name = drop_index.main_schema_name;
|
||||||
$BODY$;
|
$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" (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;
|
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');
|
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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT set_is_distinct_flag('"public"."testNs"', 'Device_id', TRUE);
|
SELECT set_is_distinct_flag('"public"."testNs"', 'Device_id', TRUE);
|
||||||
@ -96,9 +96,9 @@ FROM meta;
|
|||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM hypertable;
|
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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
@ -200,9 +200,9 @@ FROM meta;
|
|||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM hypertable;
|
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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
@ -411,6 +411,16 @@ Index "_sys_1_testNs._hyper_1_distinct_pkey"
|
|||||||
value | text | value | extended
|
value | text | value | extended
|
||||||
primary key, btree, for table "_sys_1_testNs._hyper_1_distinct"
|
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"
|
Table "_sys_1_testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
Column | Type | Modifiers | Storage | Stats target | Description
|
||||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||||
@ -563,6 +573,16 @@ Index "_sys_1_testNs._hyper_1_distinct_pkey"
|
|||||||
value | text | value | extended
|
value | text | value | extended
|
||||||
primary key, btree, for table "_sys_1_testNs._hyper_1_distinct"
|
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"
|
Table "_sys_1_testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
Column | Type | Modifiers | Storage | Stats target | Description
|
||||||
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
-----------------------------------------------------------------+------------------+-----------+----------+--------------+-------------
|
||||||
@ -787,6 +807,16 @@ Index "_sys_1_testNs._hyper_1_distinct_pkey"
|
|||||||
value | text | value | extended
|
value | text | value | extended
|
||||||
primary key, btree, for table "_sys_1_testNs._hyper_1_distinct"
|
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"
|
Table "_sys_1_testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
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");
|
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id");
|
||||||
SELECT * FROM add_hypertable('"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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT * FROM hypertable;
|
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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT * FROM hypertable_index;
|
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_2) WHERE series_2 IS NOT NULL;
|
||||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_bool) WHERE series_bool 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' );
|
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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE);
|
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
|
value | text | value | extended
|
||||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
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"
|
Table "testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
Column | Type | Modifiers | Storage | Stats target | Description
|
||||||
-------------+------------------+-----------+----------+--------------+-------------
|
-------------+------------------+-----------+----------+--------------+-------------
|
||||||
@ -438,6 +448,16 @@ Child tables: "testNs"._hyper_1_0_distinct
|
|||||||
value | text | value | extended
|
value | text | value | extended
|
||||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
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"
|
Table "testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
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_2) WHERE series_2 IS NOT NULL;
|
||||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, series_bool) WHERE series_bool 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' );
|
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
|
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 | 1 | STICKY | time | bigint | Test1
|
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)
|
(1 row)
|
||||||
|
|
||||||
SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE);
|
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
|
value | text | value | extended
|
||||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
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"
|
Table "testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
Column | Type | Modifiers | Storage | Stats target | Description
|
||||||
-------------+------------------+-----------+----------+--------------+-------------
|
-------------+------------------+-----------+----------+--------------+-------------
|
||||||
@ -438,6 +448,16 @@ Child tables: "testNs"._hyper_1_0_distinct
|
|||||||
value | text | value | extended
|
value | text | value | extended
|
||||||
primary key, btree, for table "testNs._hyper_1_distinct"
|
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"
|
Table "testNs._hyper_1_root"
|
||||||
Column | Type | Modifiers | Storage | Stats target | Description
|
Column | Type | Modifiers | Storage | Stats target | Description
|
||||||
-------------+------------------+-----------+----------+--------------+-------------
|
-------------+------------------+-----------+----------+--------------+-------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user