Seite 1 von 1

Unique contraint and index

Verfasst: Di 14. Aug 2018, 10:52
von Nunki
Dear all,

When I define a unique contraint like

Code: Alles auswählen

ALTER TABLE Documents ADD CONSTRAINT Documents_pk PRIMARY KEY (id,bid);
will that be enough to prevent full table scans ?
Or should I also define the index

Code: Alles auswählen

CREATE INDEX DocumentsI ON Documents(id,bid);
regards,
Nunki

Re: Unique contraint and index

Verfasst: Di 14. Aug 2018, 11:39
von akretschmer
the primary key constraint will implicit create the index. If the index will be usefull to prevent full table scans depends on the query. You can use explain to check.

And yes: this is a germany speaking forum, can we switch to german?