Re: [HACKERS] Re: about 7.0 LIMIT optimization

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Re: about 7.0 LIMIT optimization
Дата
Msg-id 29759.951359429@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Re: about 7.0 LIMIT optimization  (Don Baccus <dhogaza@pacifier.com>)
Ответы Re: [HACKERS] Re: about 7.0 LIMIT optimization  (Don Baccus <dhogaza@pacifier.com>)
Список pgsql-hackers
Don Baccus <dhogaza@pacifier.com> writes:
>> For example, if you want the 10 best rows from 100000, these are the
> average numbers of comparisons:
>> 
>> QuickSort: 1.6E+14
>> SortStop: 1.5E+11

Are there some zeroes missing here?  That sounds like an awful lot of
operations for a quicksort of only 1E5 elements...

> This makes sense ... you can stop once you can guarantee that the first
> ten rows are in proper order.  I'm not familiar with the algorithm
> but not terribly surprised that one exists.

The obvious way to do it would be with a heap-based sort.  After you've
built the heap, you pull out the first ten elements and then stop.
Offhand this only seems like it'd save about half the work, though,
so maybe Roberto has a better idea.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: about 7.0 LIMIT optimization
Следующее
От: Don Baccus
Дата:
Сообщение: Re: [HACKERS] Re: about 7.0 LIMIT optimization