Gre*_*een 10 postgresql unique
由于Postgres 10正确支持哈希索引,我想使用哈希索引进行id查找(哈希索引的大小比btree小,理论上更快).
我有一张桌子
create table t (id int);
create unique index on t using hash (id);
Run Code Online (Sandbox Code Playgroud)
但我得到以下内容:
ERROR: access method "hash" does not support unique indexes
为什么哈希索引不允许唯一约束?有办法绕过这个吗?
您可以使用排除约束来实现此目的:
create table t (id int);
alter table t add constraint c exclude using hash (id with =);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1716 次 |
| 最近记录: |