Re: [HACKERS] Group by, count, order by and limit

Поиск
Список
Период
Сортировка
Искать

Re: [HACKERS] Group by, count, order by and limit

От:
"Shridhar Daithankar<shridhar_daithankar@persistent.co.in>" <shridhar_daithankar@persistent.co.in>
Дата:
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
FAQ