Re: another index question - Mailing list pgsql-general

From Tom Lane
Subject Re: another index question
Date
Msg-id 920.986160154@sss.pgh.pa.us
Whole thread Raw
In response to another index question  (Sean Harding <sharding@dogcow.org>)
Responses Re: another index question
List pgsql-general
OK, indeed this is a bug --- the planner has a bad interaction for LIMIT
clauses used in "IN" subselects.  Will fix.

You could avoid the bug, and get a better plan at the top level anyway,
by writing

SELECT frm,rcpt,subject FROM mesg_headers WHERE mesgnum = (SELECT mesgnum
FROM mesg_headers ORDER BY mesgnum DESC LIMIT 1);

Since you know the subselect is going to produce exactly one tuple,
there's no need to use IN.

            regards, tom lane

pgsql-general by date:

Previous
From: "ADBAAMD"
Date:
Subject: Re: Ok, why isn't it using *this* index?
Next
From: Joel Burton
Date:
Subject: Can I get the default value for an attribute (field) ?