gpt4 book ai didi

postgresql - 具有唯一约束的 Postgres 哈希索引

转载 作者:行者123 更新时间:2023-11-29 11:15:47 25 4
gpt4 key购买 nike

随着 Postgres 10 正确支持哈希索引,我想使用哈希索引进行 id 查找(与 btree 相比,哈希索引的大小更小,理论上更快)。

我有一张 table

create table t (id int);
create unique index on t using hash (id);

但是我得到了以下信息:

错误:访问方法“hash”不支持唯一索引

为什么哈希索引不允许唯一约束?有什么办法可以避免这种情况?

最佳答案

The documentation毫无疑问:

Currently, only B-tree indexes can be declared unique.

有一个discussion on the hackers list最近对此进行了讨论,得出的结论是添加允许 UNIQUE 哈希索引的功能并不简单。

关于postgresql - 具有唯一约束的 Postgres 哈希索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44274080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com