query should use an index?

From: Bopolissimus Platypus <bopolissimus(at)sni(dot)ph>
To: pgsql-general(at)postgresql(dot)org
Subject: query should use an index?
Date: 2004-01-10 08:26:22
Message-ID: 200401101626.22371.bopolissimus@sni.ph
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hello,

i've got a table that looks like this (irrelevant data removed);

create table test (
id serial primary key,
t_end timestamp);

there's an index:
create index test_t_end on test(t_end);

can or should a query like:

select login,t_end from test order by t_end desc;

use the index? explain says it does a sequential scan
and sort. but it seems to me that if it's possible for the
postgresql to use the index to seek to the last record and
then step backward, then it could use the index. but of
course i don't know anything about postgresql internals
so i'm really just guessing or going with what seems likely,
but from a position of ignorance.

tiger

--
Gerald Timothy Quimpo gquimpo*hotmail.com tiger*sni*ph
http://bopolissimus.sni.ph
Public Key: "gpg --keyserver pgp.mit.edu --recv-keys 672F4C78"

The best way to get rid of worries is to let them die of
neglect.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2004-01-10 09:57:25 Re: query should use an index?
Previous Message Oleg Bartunov 2004-01-10 08:19:35 Re: Hierarchical queries