Re: qsort, once again

Поиск
Список
Период
Сортировка
От Jonah H. Harris
Тема Re: qsort, once again
Дата
Msg-id 36e682920603161232r15d26bf5ld9c16b0fe653528e@mail.gmail.com
обсуждение исходный текст
Ответ на Re: qsort, once again  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: qsort, once again  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 3/16/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
So we still have a problem of software archaeology: who added the
insertion sort switch to the NetBSD version, and on what grounds?


AFAICS, the insertion sort was added in BSD 4.4-lite and was inherited by NetBSD in CVS version 1.1.1.2.

The previous version in NetBSD (before 4.4-lite) also included an insertion sort with the comment:

/*
* Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass
* of straight insertion sort after partitioning is complete is better than
* sorting each small partition as it is created. This isn't correct in this
* implementation because comparisons require at least one (and often two)
* function calls and are likely to be the dominating expense of the sort.
* Doing a final insertion sort does more comparisons than are necessary
* because it compares the "edges" and medians of the partitions which are
* known to be already sorted.
*
* This is also the reasoning behind selecting a small THRESH value (see
* Knuth, page 122, equation 26), since the quicksort algorithm does less
* comparisons than the insertion sort.
*/


--
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporation
732.331.1324

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Separate BLCKSZ for data and logging
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Separate BLCKSZ for data and logging