Re: Index not used, - Mailing list pgsql-admin

From Tom Lane
Subject Re: Index not used,
Date
Msg-id 9519.1049916508@sss.pgh.pa.us
Whole thread Raw
In response to Re: Index not used,  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-admin
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> On Wed, 9 Apr 2003, Cris wrote:
>> I've created an index on (id,op,tt) to improve the next query, that is executed very often:
>> "SELECT * FROM BB WHERE id="+ id+" AND op=0 order by tt desc;";
>> (because the only row I need is the one that has the highest tt)

> You might want to use limit 1 then to prevent it from getting all the rest
> of the rows as well.

Also, I think you'll need to say "ORDER BY id, op, tt" to get it to
realize that the index matches the required ordering.

            regards, tom lane


pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: [JDBC] Problems with Large Objects using Postgres 7.2.1
Next
From: Robert Treat
Date:
Subject: Re: trouble connecting to Postgresql Database via