Re: [HACKERS] Group by, count, order by and limit - Mailing list pgsql-general

From Shridhar Daithankar
Subject Re: [HACKERS] Group by, count, order by and limit
Date
Msg-id 200302181111.38250.shridhar_daithankar@persistent.co.in
Whole thread Raw
List pgsql-general
On Tuesday 18 Feb 2003 9:56 am, you wrote:
> My 3rd attempt to post ...
>
> Consider this query on a large table with lots of different IDs:
>
>     SELECT id FROM my_table GROUP BY id ORDER BY count(id) LIMIT 10;
>
> It has an index on id.  Obviously, the index helps to evaluate count(id)
> for a given value of id, but count()s for all the `id's should be
> evaluated, so sort() will take most of the time.

First, what does explain analyze say

Second, wild shot, how much difference does it make with different sort_mem
settings?

 Shridhar

pgsql-general by date:

Previous
From: "Shridhar Daithankar"
Date:
Subject: Re: Table Partitioning in Postgres:
Next
From: Christopher Murtagh
Date:
Subject: Re: pg_dump --> restore loses constraints/triggers?