Re: Optimizer sorting an already sorted result - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Optimizer sorting an already sorted result
Date
Msg-id 12174.1209520924@sss.pgh.pa.us
Whole thread Raw
In response to Optimizer sorting an already sorted result  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
List pgsql-hackers
"Gurjeet Singh" <singh.gurjeet@gmail.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


pgsql-hackers by date:

Previous
From: "Gurjeet Singh"
Date:
Subject: Optimizer sorting an already sorted result
Next
From: Hannu Krosing
Date:
Subject: Re: Protection from SQL injection