【发布时间】:2021-09-05 00:53:36
【问题描述】:
我正在使用带有新创建的表的 Timescaledb 2.3.0 版。我有下表(已编辑):
local=# \d+ dock_status;
Table "public.dock_status"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------------------+--------------------------+-----------+----------+---------+----------+--------------+-------------
id | uuid | | not null | | plain | |
dock_id | uuid | | | | plain | |
created_at | timestamp with time zone | | not null | | plain | |
updated_at | timestamp with time zone | | | | plain | |
deleted_at | timestamp with time zone | | | | plain | |
is_pwr_btn_enabled | boolean | | | | plain | |
Indexes:
"dock_status_pkey" PRIMARY KEY, btree (id)
"unique_index_dock_status_created_at" UNIQUE, btree (created_at)
Access method: heap
我尝试通过以下方式创建超表:
SELECT create_hypertable('dock_status', 'created_at', migrate_data => true, if_not_exists => true);
错误信息是:
ERROR: cannot create a unique index without the column "created_at" (used in partitioning)
根据this,我应该为 created_at 创建一个唯一索引,我这样做了。那么到底出了什么问题呢?
【问题讨论】:
-
这个答案有帮助吗? stackoverflow.com/a/66041772/840340 里面提到不需要唯一索引,如果需要,则需要包含时间列。
标签: sql postgresql timescaledb