PostgreSQL: Corrupt primary key, inconsistent table
There are various ways this can happen in Oracle - I'm not sure about postgres, but I think I would call this an "integrity violation" rather than "corruption"

Perhaps you can do one of the things suggested here, ie set enable_indexscan = off or 

begin;
drop index rank_details_pkey;
select user_id, count(*) from rank_details group by user_id having count(*) &gt; 1;
rollback;


But "there are likely some locking issues with this, so be careful with it in production"

The idea is to force the query to scan the table rather than just the index (which does not have the duplicates). You may also, and more simply, be able to acheive the same by:

select user_id, f(&lt;some other column&gt;), count(*)
from rank_details
group by user_id, f(&lt;some other column&gt;)
having count(*) &gt; 1


where f() returns a constant, which may trick the planner into a table scan.