Sorry i could not replicate that issue . But here is something which was the original problem and is replicable.
Regds Mallah.
rt2=# CREATE UNIQUE INDEX users_1 on users_sample(name); ERROR: could not create unique index DETAIL: Table contains duplicated values. rt2=# rt2=# SELECT name from users_sample group by name having count(*) > 1 limit 20; +------+ | name | +------+ +------+ (0 rows)
Time: 766.725 ms rt2=# SELECT version(); rt2=# SELECT name from users_sample group by name having count(*) > 1 ; +------+ | name | +------+ +------+ (0 rows)
Time: 905.586 ms rt2=# SELECT version(); +----------------------------------------------------------------------------------------------------------+ | version | +----------------------------------------------------------------------------------------------------------+ | PostgreSQL 7.4.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-34) | +----------------------------------------------------------------------------------------------------------+ (1 row)
rt2=# SELECT name from users group by name having count(*) > 1 limit 20;
(4 rows)
rt2=# SELECT name from users group by name having count(*) > 1 ;
(0 rows)
Weird. What PG version is this? What does EXPLAIN show for each of
these queries (maybe EXPLAIN ANALYZE too)? Can you provide a
self-contained test case?
regards, tom lane