Postgres,重复唯一索引 [英] Postgres, duplicate unique index

查看:184
本文介绍了Postgres,重复唯一索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为哈希的唯一索引列

I have a unique index column named "hash"

但是当我运行查询时:

 SELECT *
 FROM urls_0
 WHERE hash = '\x0009cb31d8a6c0c64f6877c22a781804'::bytea

有两行,由于唯一的冲突,我无法为该索引重新编制索引。这里发生什么。我正在使用PostgreSQL 9.3.2

There are two rows and I can not reindex that index because of unique violation. What happen here. I'm using PostgreSQL 9.3.2

推荐答案

如果您使用CREATE INDEX CONCURRENTLY子句,可能会发生。

It could happen if you use CREATE INDEX CONCURRENTLY clause.

来自文档


如果在扫描表时出现问题,例如唯一性冲突索引,CREATE INDEX命令将失败,但留下无效索引。该索引出于查询目的将被忽略,因为它可能不完整。但是它仍然会消耗更新开销。

If a problem arises while scanning the table, such as a uniqueness violation in a unique index, the CREATE INDEX command will fail but leave behind an "invalid" index. This index will be ignored for querying purposes because it might be incomplete; however it will still consume update overhead.

这篇关于Postgres,重复唯一索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆