Re: Bidirectional index traversal

From: Alanoly Andrews <alanolya(at)invera(dot)com>
To: 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'pgsql-admin(at)postgresql(dot)org'" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Bidirectional index traversal
Date: 2010-09-16 15:02:07
Message-ID: 09B23E7BF70425478C1330D893A722C602FEC01A2D@MailSVR.invera.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

To expand on that question:

Suppose I have a table with the following schema:
tab1(col1 decimal(3,0), col2 char(3)).
There is an index defined on it as : create index tab1ind1 on tab1(col1)

Now, if I have a query as: "select * from tab1 order by col1", I expect the Optimizer to use the index tab1ind1. But if I have a query like: "select * from tab1 order by col1 desc", does the Postgres Optimizer use the same index as above (but in the reverse direction) or does it need to a full table scan and then sort values in col1 in the descending order? If the former, then there is bidirectional index traversal. That example was for a numeric field. What about character, date and timestamp fields? Does bidirectional index traversal exist, or do we need to create a second index to handle such cases?

Alanoly.

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Thursday, September 16, 2010 10:57 AM
To: Alanoly Andrews
Cc: 'pgsql-admin(at)postgresql(dot)org'
Subject: Re: [ADMIN] Bidirectional index traversal

Alanoly Andrews <alanolya(at)invera(dot)com> writes:
> I'd like to know whether Postgres (8.4) supports bidirectional traversal of indexes.

If you defined exactly what you meant by that, you might get useful
answers. There are some features in there that might be what you mean,
or then again maybe not.

regards, tom lane
****************************************************
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courriel est confidentiel et protg. L'expditeur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) dsign(s) est interdite. Si vous recevez ce courriel par erreur, veuillez m'en aviser immdiatement, par retour de courriel ou par un autre moyen.
****************************************************

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2010-09-16 15:14:35 Re: Bidirectional index traversal
Previous Message Tom Lane 2010-09-16 14:56:30 Re: Bidirectional index traversal