From: Jean-Luc Lachance <jllachan@nsd.ca>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pg-admin <pgsql-admin@postgresql.org>
Subject: Re: Useless index
Date: Thu, 14 Feb 2002 11:40:07 -0500
Message-ID: <3C6BE867.3635E176@nsd.ca> (raw)
References: <200202141542.g1EFgSV28050@candle.pha.pa.us>
<9035.1013702751@sss.pgh.pa.us>
Here is another peeve
Having to specify the type of a constant in a SELECT DISTINCT 'foo'...
I which I had more spare time to contribute...
Jean-Luc
Tom Lane wrote:
>
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > In fact, I am unsure why you are specifying the primary column in the
> > ORDER BY anyway if you know it will be a single value, except perhaps to
> > try and get it to use the index, right?
>
> Exactly. The sort ordering of the index is (col1,col2) while the
> query as originally written wanted an ordering of (col2 desc).
> The planner's not smart enough to realize that since the WHERE
> constrains col1 to a single value, you could pretend the query
> requests an ordering of (col1 desc, col2 desc) which is compatible
> with the index.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jllachan@nsd.ca, tgl@sss.pgh.pa.us
Subject: Re: Useless index
In-Reply-To: <3C6BE867.3635E176@nsd.ca>
References: <200202141542.g1EFgSV28050@candle.pha.pa.us> <9035.1013702751@sss.pgh.pa.us> <3C6BE867.3635E176@nsd.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox