Re: Index not used,

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Cris <cris(at)dmcid(dot)net>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Index not used,
Date: 2003-04-09 19:28:28
Message-ID: 9519.1049916508@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-jdbc

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Cris 2003-04-09 19:42:17 Index not used,
Previous Message Tom Lane 2003-04-09 19:20:13 Re: [JDBC] Problems with Large Objects using Postgres 7.2.1

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jason Dinger 2003-04-09 19:40:40 tomcat/postgres problem
Previous Message Tom Lane 2003-04-09 19:20:13 Re: [JDBC] Problems with Large Objects using Postgres 7.2.1