Re: Evaluation of secondary sort key. - Mailing list pgsql-hackers

From Jesper Krogh
Subject Re: Evaluation of secondary sort key.
Date
Msg-id 4DA0AB2B.9050408@krogh.cc
Whole thread Raw
In response to Re: Evaluation of secondary sort key.  (David Fetter <david@fetter.org>)
List pgsql-hackers
On 2011-04-09 20:00, David Fetter wrote:
> Given the horrors query generators perpetrate, it might be worth
> dropping provably redundant ORDER BYs on the floor at planning time.
Well, many people often add a secondary sort-key to their SQL
for the only purpose of obtainting a consistent result in the
corner-cases where the first sort key is ambiguios.

If the first sort-key isn't planned to be supported by an index-scan,
then you'll end up calculating the second sortkey for the entire
dataset even if you end up doing a "limit 100" at the end.

You can only deem it redundant if there is a primary key in front.
if you have a primary key in front, where as a fix may be really
good in cases where you have a "n_distinct" at or near -1 in pg_stats
for the column.

Jesper
-- 
Jesper


pgsql-hackers by date:

Previous
From: Joshua Berkus
Date:
Subject: Feature request: pg_basebackup --force
Next
From: Jesper Krogh
Date:
Subject: Re: Evaluation of secondary sort key.