diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-04 01:13:45 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-04 01:13:45 +0000 |
commit | d26559dbf356736923b26704ce76ca820ff3a2b0 (patch) | |
tree | e899e3b4eb9f0d34f598816f69a9a60379987391 /src/include/postgres.h | |
parent | 0fef38da215cdc9b01b1b623c2e37d7414b91843 (diff) | |
download | postgresql-d26559dbf356736923b26704ce76ca820ff3a2b0.tar.gz postgresql-d26559dbf356736923b26704ce76ca820ff3a2b0.zip |
Teach tuplesort.c about "top N" sorting, in which only the first N tuples
need be returned. We keep a heap of the current best N tuples and sift-up
new tuples into it as we scan the input. For M input tuples this means
only about M*log(N) comparisons instead of M*log(M), not to mention a lot
less workspace when N is small --- avoiding spill-to-disk for large M
is actually the most attractive thing about it. Patch includes planner
and executor support for invoking this facility in ORDER BY ... LIMIT
queries. Greg Stark, with some editorialization by moi.
Diffstat (limited to 'src/include/postgres.h')
0 files changed, 0 insertions, 0 deletions