Linking tables and indexes

From: Jorge Godoy <jgodoy(at)gmail(dot)com>
To: PostgreSQL General ML <pgsql-general(at)postgresql(dot)org>
Subject: Linking tables and indexes
Date: 2007-01-16 00:52:08
Message-ID: 87wt3nkd3b.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi!

I'm not sure about the English terminology for that so I'm sorry if I made a
mistake on the subject and on this message. I hope de code explains it better
if I missed it :-)

I have some tables that will have N:M relationships between themselves and for
that I created some linking tables such as:

CREATE TABLE ged.documents_clients_cis (
ci_id INT NOT NULL,
CONSTRAINT ci_id_exists
FOREIGN KEY (ci_id)
REFERENCES ged.cis (id) ,
document_client_id INT NOT NULL,
CONSTRAINT document_client_id_exists
FOREIGN KEY (document_client_id)
REFERENCES ged.documents_clients (id),
PRIMARY KEY (ci_id, document_client_id)
);

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).

Thanks for your attention,
--
Jorge Godoy <jgodoy(at)gmail(dot)com>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chad Wagner 2007-01-16 00:54:51 Re: Improve Postgres Query Speed
Previous Message carter ck 2007-01-16 00:44:57 Improve Postgres Query Speed