query should use an index? - Mailing list pgsql-general

From Bopolissimus Platypus
Subject query should use an index?
Date
Msg-id 200401101626.22371.bopolissimus@sni.ph
Whole thread Raw
Responses Re: query should use an index?
List 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.

pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: Hierarchical queries
Next
From: Peter Eisentraut
Date:
Subject: Re: query should use an index?