我使用的是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我尝试通过以下方式创建hypertable:
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创建一个唯一的索引,我也这么做了。那么到底出了什么问题呢?
发布于 2021-06-21 18:46:36
"hypertable“是PostgreSQL分区周围的一层薄层。
分区表上的索引是分区索引-它由每个表分区上的索引组成。这样的索引可以全局唯一的唯一方式是,根据定义它是唯一的,即包含分区键作为索引列。
这是一个PostgreSQL限制,但是您应该准备好为分区的好处付出代价。可以支持全局唯一索引的“全局索引”将从分区中获得很多乐趣。
https://stackoverflow.com/questions/68066433
复制相似问题