Reputation: 17873
in postgres, just checking if we need to index all columns of composite primary key
CREATE TABLE BOOK_TYPE(
ID TEXT NOT NULL,
TYPE TEXT NOT NULL,
LABELS HSTORE NOT NULL,
CONSTRAINT BOOK_TYPE_PKEY PRIMARY KEY (ID,TYPE)
);
should I have to index ID and type separately?
Upvotes: 0
Views: 68
Reputation: 246403
You don't need to create any extra index unless you happen to need it to speed up a query. The primary key will automatically create a unique index on (id, type)
, and that is all that is needed to guarantee consistency.
Upvotes: 1