Re: Order by and index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jonathan Tse <dev(at)tsez(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Order by and index
Date: 2005-10-05 14:50:06
Message-ID: 18676.1128523806@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Jonathan Tse <dev(at)tsez(dot)net> writes:
> It is good. However, if I execute the following query:

> select * from t_post where ownerid = 2
> order by t_stamp

> The query planner doesn't use the index for sorting.

Try "order by ownerid, t_stamp".

Postgres 8.1 will recognize that the where clause makes it OK to
consider the ORDER BY as matching the index order, but existing
releases do not know that.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-10-05 16:23:56 Re: Moving from MySQL
Previous Message Daniel T. Staal 2005-10-05 13:51:31 Re: Missing file LIBC06P1