pgsql: Improve performance of our private version of qsort.

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve performance of our private version of qsort.
Date: 2006-03-21 19:49:19
Message-ID: 20060321194919.47EFE9DCA0F@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Improve performance of our private version of qsort. Per recent testing,
the logic it contained to switch to insertion sort for near-sorted input was
in fact a big loss, because it could fairly easily be fooled into applying
insertion sort to large subfiles that weren't all that well ordered. Remove
that, and instead add a simple check for already-perfectly-sorted input, as
per suggestion from Dann Corbit. This adds at worst O(N*lgN) overhead, and
usually far less, while sometimes allowing a subfile sort to finish in O(N)
time. Preliminary testing says this is an improvement over the basic
Bentley & McIlroy code for many nonrandom inputs, and it costs almost
nothing when the input is random.

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
pgsql/src/port:
qsort.c (r1.8 -> r1.8.2.1)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/port/qsort.c.diff?r1=1.8&r2=1.8.2.1)

Browse pgsql-committers by date

  From Date Subject
Next Message User Aparashar 2006-03-22 07:15:53 bizgres - bizgres: Teach nodeSort and nodeMaterial to optimize out
Previous Message Tom Lane 2006-03-21 19:49:15 pgsql: Improve performance of our private version of qsort.