Re: Backwards index scan

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Backwards index scan
Date: 2006-06-06 15:04:45
Message-ID: 200606060804.45516@hal.medialogik.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On June 6, 2006 07:59 am, "Carlos Oliva" <carlos(at)pbsinet(dot)com> wrote:
> We are conducting a simple test to asses if the optimizer ever uses the
> index. The table has several columns and the select statement is as
> follows: select * from ord0007 order by prtnbr, ordschdte desc. The
> index that we added is "ord0007_k" btree (prtnbr, ordschdte). Prtnbr is
> numeric(10,0) not null, and ordschdte is date.

You have to "order by prtnbr desc, ordschdte desc" to have the index used
the way you want. You can re-order in an outer query if you need to.

--
Alan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2006-06-06 15:23:35 Re: ALTER USER ..... PASSWORD ....
Previous Message Carlos Oliva 2006-06-06 14:59:30 Backwards index scan