1

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

4
  • Are you 100% sure that this unique index exists for the table urls_0 solely on the column named hash? Commented Feb 16, 2014 at 13:55
  • Please, could you connect to the database, execute the following query and post the result here? SELECT indexrelid::regclass, indisunique, indisvalid FROM pg_catalog.pg_index WHERE indrelid = 'urls_0'::regclass; Commented Feb 16, 2014 at 15:43
  • @MarceloZabani: I'm sure Commented Feb 18, 2014 at 17:30
  • @MatheusOl: The result is true all. But I have fixed my system by manual removed the duplicated row. Commented Feb 18, 2014 at 17:33

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I think may be this is the right answer, but I do not use CREATE INDEX CONCURRENTLY. The index is created very first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.