Re: Memory usage during sorting

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: Memory usage during sorting
Дата
Msg-id CAEYLb_XMuYTYy1huzJ3A1u31AJ5eN5Ro9ySP804M7j_N4bWQeA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Memory usage during sorting  (Peter Geoghegan <peter@2ndquadrant.com>)
Ответы Re: Memory usage during sorting  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
On 14 April 2012 14:34, Peter Geoghegan <peter@2ndquadrant.com> wrote:
> FWIW, I started playing with adding timsort to Postgres last night:
>
> https://github.com/Peter2ndQuadrant/postgres/tree/timsort

I've fixed this feature-branch so that every qsort_arg call site
(including the tuplesort specialisations thereof) call timsort_arg
instead. All but 4 regression tests pass, but they don't really count
as failures, since they're down to an assumption in the tests that the
order certain tuples appear should be the same as our current
quicksort implementation returns them, even though, in these
problematic cases, that is partially dictated by implementation - our
quicksort isn't stable, but timsort is. I think that the original
tests are faulty, but I understand that they're only expected to
provide smoke testing.

I did have to fix one bug in the implementation that I found, which
was an assumption that comparators would only return one of {-1, 0,
1}. The C standard requires only that they return negative, zero or
positive values, as required. I also polished the code a bit, and
added more comments.

I haven't actually quantified the benefits yet, and have no numbers to
show just yet, but I suspect it will prove to be a fairly compelling
win in certain situations.

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services


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

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: 9.3 Pre-proposal: Range Merge Join
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: 9.3 Pre-proposal: Range Merge Join