Re: Selecting dupes from table
От | Martijn van Oosterhout |
---|---|
Тема | Re: Selecting dupes from table |
Дата | |
Msg-id | 20030624103252.GD19206@svana.org обсуждение исходный текст |
Ответ на | Selecting dupes from table (Uros <uros@sir-mag.com>) |
Ответы |
Re: Selecting dupes from table
|
Список | pgsql-general |
On Tue, Jun 24, 2003 at 12:16:43PM +0200, Uros wrote: > Hello , > > I have table directory with 3 columns (id,url,title) > > I want to list all entries with duplicate urls. > > I tried this: > > select id,url,title from directory where url IN > (select url from directory group by url having count(url) > 1) > ORDER by url; > > but this takes 30 seconds with 25.000 entries. I have index on url. > > Can I use any other query to select this faster. How about: Duplicate urls would be given by: select url from directory group by url having count(*) > 1; To get all the entries with those urls, something like: select id,url,title from directory, (select url from directory group by url having count(*) > 1) as list where list.url = directory.url; I hope I got the syntax right. -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > "the West won the world not by the superiority of its ideas or values or > religion but rather by its superiority in applying organized violence. > Westerners often forget this fact, non-Westerners never do." > - Samuel P. Huntington
Вложения
В списке pgsql-general по дате отправления: