Re: Optimizing DISTINCT with LIMIT
| От | Tom Lane |
|---|---|
| Тема | Re: Optimizing DISTINCT with LIMIT |
| Дата | |
| Msg-id | 24128.1228401326@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Optimizing DISTINCT with LIMIT (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>) |
| Ответы |
Re: Optimizing DISTINCT with LIMIT
|
| Список | pgsql-hackers |
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> Gregory Stark wrote:
>> 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?
In principle, if there are no aggregate functions, then nodeAgg could
return a row immediately upon making any new entry into the hash table.
Whether it's worth the code uglification is debatable ... I think it
would require a third major pathway through nodeAgg.
regards, tom lane
В списке pgsql-hackers по дате отправления: