Re: Would an index benefit select ... order by?

From: rihad <rihad(at)mail(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Cc: andreas(dot)kretschmer(at)schollglas(dot)com
Subject: Re: Would an index benefit select ... order by?
Date: 2007-11-04 08:56:42
Message-ID: 472D894A.3000500@mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> Should an index be used on a created_at timestamp column if you know you
>> will be using "ORDER BY created_at ASC|DESC" from time to time?
>
> Yes.

Thanks. This is stated explicitly in 8.3 docs (as opposed to 8.2)

http://www.postgresql.org/docs/8.3/static/indexes-ordering.html

> And you should use EXPLAIN.

You mean Postgres wouldn't *always* use created_at's index with such
access patterns on a big table (even if one exists):

select * from foo order by created_at desc;

?

Mind you the distribution of created_at values are going to be as
different as the time is (i.e. almost as many different values as there
are tables in the row).

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Smith 2007-11-04 09:18:59 Re: What makes a Postgres DBA?
Previous Message Greg Smith 2007-11-04 08:14:20 Re: young guy wanting (Postgres DBA) ammo