Re: Indexes - Mailing list pgsql-general

From Greg Stark
Subject Re: Indexes
Date
Msg-id 871wypsttu.fsf@stark.xeocode.com
Whole thread Raw
In response to Indexes  ("Silas Justiniano" <silasju@gmail.com>)
List pgsql-general
"Silas Justiniano" <silasju@gmail.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

pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: TSearch2 / German compound words / UTF-8
Next
From: Bohdan Linda
Date:
Subject: Little Offtopic: Database frontends