Re: is this expected or am i on crack? - Mailing list pgsql-general

From Tod McQuillin
Subject Re: is this expected or am i on crack?
Date
Msg-id Pine.GSO.4.31.0102222155270.13223-100000@sysadmin
Whole thread Raw
In response to is this expected or am i on crack?  (Chris Humphries <chumphries@siliconinc.net>)
List pgsql-general
On Sun, 18 Feb 2001, Chris Humphries wrote:

>              Table "facts"
>   Attribute  |     Type     | Modifier
> -------------+--------------+----------
>  keyword     | varchar(80)  |
>  description | varchar(255) |
>  url         | varchar(255) |
>
> select keyword from facts as f1
> where 1 <> (select count(*) from facts as f2 where f1.keyword = f2.keyword)
> order by keyword;
>
> it took about 65 minutes to complete. i know that it is doing alot of work,
> but it there a way that it could be sped up, like something i could configure
> or something that i could do to make it faster?

Hm, this will probably run the subquery for every row in the table.  Try:

select keyword, count(keyword) from facts
group by keyword
having 1 <> count(keyword)
order by count(keyword) desc

Is this any faster?
--
Tod McQuillin



pgsql-general by date:

Previous
From: Ian Lance Taylor
Date:
Subject: Re: Building SPI programs
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Re: [INTERFACES] Re: Chinese patch for Pgaccess