Thread: cluster index on primary key
Hi there, I'd like to know when I create a primary key on a table, does postgres will create automatically an index on that table related to the primary key columns, or I have to create it explicitly ? If I have to create it explicitly, suppose I have tables with a serial primary key, or link tables with multiple column primary key. How is recommended for the two cases: to create an index on the primary key unique, or cluster or both or with none of the two options ? TIA, Sabin
On 6/11/07, Sabin Coanda <sabin.coanda@deuromedia.ro> wrote: > I'd like to know when I create a primary key on a table, does postgres will > create automatically an index on that table related to the primary key > columns, or I have to create it explicitly ? From http://www.postgresql.org/docs/8.2/static/indexes-unique.html : "PostgreSQL automatically creates a unique index when a unique constraint or a primary key is defined for a table. The index covers the columns that make up the primary key or unique columns (a multicolumn index, if appropriate), and is the mechanism that enforces the constraint."