enabled hypertables, from pg to timescale

This commit is contained in:
marius 2023-05-06 17:10:01 +00:00
parent 5d992e89bd
commit 45bcf4e754

View File

@ -0,0 +1,53 @@
postgres@loglab:/etc/postgresql/14/main$ psql
psql (15.2 (Ubuntu 15.2-1.pgdg20.04+1), server 14.7 (Ubuntu 14.7-1.pgdg20.04+1))
Type "help" for help.
postgres=# CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
NOTICE: extension "timescaledb" already exists, skipping
CREATE EXTENSION
postgres=# SELECT extname FROM pg_extension WHERE extname = 'timescaledb';
extname
-------------
timescaledb
(1 row)
postgres=# SELECT create_hypertable('logs', 'timestamp');
ERROR: cannot create a unique index without the column "timestamp" (used in partitioning)
postgres=# SELECT
postgres-# i.relname AS index_name,
postgres-# a.attname AS column_name
postgres-# FROM
postgres-# pg_class t,
postgres-# pg_class i,
postgres-# pg_index ix,
postgres-# pg_attribute a
postgres-# WHERE
postgres-# t.oid = ix.indrelid
postgres-# AND i.oid = ix.indexrelid
postgres-# AND a.attrelid = t.oid
postgres-# AND a.attnum = ANY(ix.indkey)
postgres-# AND t.relkind = 'r'
postgres-# AND t.relname = 'logs'
postgres-# AND ix.indisunique IS TRUE;
index_name | column_name
------------+-------------
logs_pkey | id
(1 row)
postgres=# ALTER TABLE logs DROP CONSTRAINT logs_pkey;
ALTER TABLE
postgres=# CREATE UNIQUE INDEX logs_unique_id_timestamp ON logs (id, timestamp);
CREATE INDEX
postgres=# SELECT create_hypertable('logs', 'timestamp');
create_hypertable
-------------------
(3,public,logs,t)
(1 row)
postgres=# SELECT extname FROM pg_extension WHERE extname = 'timescaledb';
extname
-------------
timescaledb
(1 row)
postgres=# \q