Search Postgresql Archives

Re: Indexes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Silas Justiniano" <silasju@xxxxxxxxx> 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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux