问题
I have a unique index column named "hash"
However when I run query:
SELECT *
FROM urls_0
WHERE hash = '\x0009cb31d8a6c0c64f6877c22a781804'::bytea
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
回答1:
It could happen if you use CREATE INDEX CONCURRENTLY clause.
from documentation:
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.
来源:https://stackoverflow.com/questions/21811753/postgres-duplicate-unique-index