agora inbox for pgsql-general@postgresql.org  
help / color / mirror / Atom feed
From: Poul Møller Hansen <freebsd@pbnet.dk>
To: pgsql-general@postgresql.org
Subject: Optimizing query
Date: Mon, 15 Aug 2005 10:38:26 +0200
Message-ID: <43005482.7020105@pbnet.dk> (raw)

I have a problem creating a usable index for the following simple query:
SELECT * FROM my.table WHERE node = '10' ORDER BY id DESC LIMIT 1

id is a serial, so the query is to find the latest entry to a given node 
and id is the primary key.
The table contains around 1 million records and the query takes around 2 
seconds.

I have tried to make an index on node and also on both id & node, but is 
doesn't lower the
query time.

What am I doing wrong ?

Thanks,
Poul




view thread (41+ messages)  latest in thread

Message-ID: <43005482.7020105@pbnet.dk>
Permalink:  ../43005482.7020105@pbnet.dk/
Also on:    postgresql.org/message-id/43005482.7020105@pbnet.dk

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 using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: freebsd@pbnet.dk
  Subject: Re: Optimizing query
  In-Reply-To: <43005482.7020105@pbnet.dk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox