Re: Optimizer sorting an already sorted result

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Cc: "PGSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Optimizer sorting an already sorted result
Date: 2008-04-30 02:02:04
Message-ID: 12174.1209520924@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com> writes:
> In the plan below, we can see that the optimizer is sorting an already
> sorted result. It seems to forget the sort order across the UNIQUE node. My
> question is, do we make any attempts in the optimizer to remember the sort
> order of a result, to avoid any further sorting on same sort-key? If not,
> can we do something about it?

Per the comment in create_unique_path:

/*
* Treat the output as always unsorted, since we don't necessarily have
* pathkeys to represent it.
*/
pathnode->path.pathkeys = NIL;

No doubt this could be improved, but I'm unsure about the effort/reward
ratio.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2008-04-30 09:01:57 Re: [0/4] Proposal of SE-PostgreSQL patches
Previous Message Gurjeet Singh 2008-04-30 01:25:30 Optimizer sorting an already sorted result