Re: Optimizing DISTINCT with LIMIT

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Optimizing DISTINCT with LIMIT
Дата
Msg-id 4937E721.2050407@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Optimizing DISTINCT with LIMIT  (Gregory Stark <stark@enterprisedb.com>)
Ответы Re: Optimizing DISTINCT with LIMIT  (Gregory Stark <stark@enterprisedb.com>)
Re: Optimizing DISTINCT with LIMIT  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Gregory Stark wrote:
> tmp <skrald@amossen.dk> writes:
> 
>>   If the input is "sufficiently" large and the LIMIT threshold "sufficiently"
>> small, maintain the DISTINCT output by hashning while traversing the input and
>> stop when the LIMIT threshold is reached. No sorting required and *at* *most*
>> one read of input.
> 
> You mean like this?
> 
> postgres=# explain select distinct x  from i limit 5;
>                             QUERY PLAN                             
> -------------------------------------------------------------------
>  Limit  (cost=54.50..54.51 rows=1 width=304)
>    ->  HashAggregate  (cost=54.50..54.51 rows=1 width=304)
>          ->  Seq Scan on i  (cost=0.00..52.00 rows=1000 width=304)
> (3 rows)

Does that know to stop scanning as soon as it has seen 5 distinct values?

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Gregory Stark
Дата:
Сообщение: Re: Optimizing DISTINCT with LIMIT
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: Optimizing DISTINCT with LIMIT