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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Teach tuplesort.c about "top N" sorting, in which only the first
Date: 2007-05-04 14:04:08
Message-ID: 18677.1178287448@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2007-05-04 14:05:57 Re: pgsql: A few fixups in error handling: mark pg_re_throw() as noreturn
Previous Message User H-saito 2007-05-04 13:17:21 psqlodbc - psqlodbc: Fixed HANDLE_ENLIST_IN_DTC.

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2007-05-04 14:31:08 Re: Boatload of warnings in CVS HEAD :-(
Previous Message Martijn van Oosterhout 2007-05-04 14:03:21 Re: Boatload of warnings in CVS HEAD :-(