Re: pgsql: Teach tuplesort.c about "top N" sorting, in which only the first - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Teach tuplesort.c about "top N" sorting, in which only the first
Date
Msg-id 18677.1178287448@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Teach tuplesort.c about "top N" sorting, in which only the first  (Magnus Hagander <magnus@hagander.net>)
Responses Re: pgsql: Teach tuplesort.c about "top N" sorting, in which only the first  (Magnus Hagander <magnus@hagander.net>)
List pgsql-committers
Magnus Hagander <magnus@hagander.net> writes:
> Is there some way to see in the generated query plan if this optimisation
> is used?

If there's a SORT just below a LIMIT (that has a limit, ie it's not just
an OFFSET), then it's potentially used.  Whether it's actually used
depends on actual row counts and widths at runtime --- you'd have to
turn on trace_sort and look at the log output to determine that.

Also, if you want to experiment, you can compile with -DDEBUG_BOUNDED_SORT
to have a GUC variable optimize_bounded_sort that disables the new code
for comparison purposes.

            regards, tom lane

pgsql-committers by date:

Previous
From: h-saito@pgfoundry.org (User H-saito)
Date:
Subject: psqlodbc - psqlodbc: Fixed HANDLE_ENLIST_IN_DTC.
Next
From: Tom Lane
Date:
Subject: Re: pgsql: A few fixups in error handling: mark pg_re_throw() as noreturn