Re: Linking tables and indexes

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Jorge Godoy <jgodoy(at)gmail(dot)com>
Cc: PostgreSQL General ML <pgsql-general(at)postgresql(dot)org>
Subject: Re: Linking tables and indexes
Date: 2007-01-16 01:23:42
Message-ID: 20070116012342.GI24671@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jorge Godoy wrote:

> Thinking about how PostgreSQL is able to use composed indices should I create
> the reverse index ("CREATE INDEX something ON ged.documents_clients_cis
> (document_client_id, ci_id)") or I'd only be wasting disk and processing?
>
> The query can be done from either side (i.e. I might know either ci_id or
> document_client_id only).

If you're in 8.1 or better, I'd suggest defining only two indexes, one
on (ci_id) and other on (document_client_id), and let the system deal
with mixing them using the bitmap scan technique when appropriate.

OTOH since the columns are probably not separately unique, you'll need
the primary key anyway, in which case leave the PK alone and create
another index on (document_client_id).

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message carter ck 2007-01-16 02:26:15 Re: Improve Postgres Query Speed
Previous Message Takayuki Tsunakawa 2007-01-16 01:20:04 Re: [HACKERS] Checkpoint request failed on version 8.2.1.