pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Cris <cris@dmcid.net>
Cc: pgsql-admin@postgresql.org
Subject: Re: Index not used,
Date: Wed, 09 Apr 2003 15:28:28 -0400
Message-ID: <9519.1049916508@sss.pgh.pa.us> (raw)
In-Reply-To: <20030409115454.P68720-100000@megazone23.bigpanda.com>
References: <20030409115454.P68720-100000@megazone23.bigpanda.com>

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




view thread (4+ messages)  latest in thread

Message-ID: <9519.1049916508@sss.pgh.pa.us>
Permalink:  ../9519.1049916508@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9519.1049916508@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, cris@dmcid.net
  Subject: Re: Index not used,
  In-Reply-To: <9519.1049916508@sss.pgh.pa.us>
  References: <20030409115454.P68720-100000@megazone23.bigpanda.com> <9519.1049916508@sss.pgh.pa.us>

* 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