From: | Greg Stark <gsstark(at)mit(dot)edu> |
---|---|
To: | "Silas Justiniano" <silasju(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Indexes |
Date: | 2006-01-30 13:56:13 |
Message-ID: | 871wypsttu.fsf@stark.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Silas Justiniano" <silasju(at)gmail(dot)com> writes:
I normally create these two indexes:
CREATE UNIQUE INDEX foo ON Intermediate(book_id, author_id);
CREATE INDEX baz ON Intermediate(author_id);
Note that the second one isn't unique.
Or you can go the other way (<author_id,book_id> and <book_id>). The only
difference would be on queries like "WHERE author_id = ? and book_id BETWEEN ?
AND ?". If you never do range scans then it will hardly matter which way you
go. I tend to do it the way above just so it matches the column order in the
table.
--
greg
From | Date | Subject | |
---|---|---|---|
Next Message | David Lang | 2006-01-30 14:32:24 | looking for consulting |
Previous Message | Bohdan Linda | 2006-01-30 13:54:09 | Little Offtopic: Database frontends |