When I read Mike's question, he asks if FK Constraint will create an index in the FK column in the table in which FK is located (Table 1). The answer is no, and in general. (for purposes of limitation), there is no need to do this. Column (s) defined as "TARGET" restrictions, on the other hand, must be a unique index in the referenced table, either a primary key or an alternate key. (unique index) or constraint creation status.
(EDIT: added for explicit consideration of the comment below) In particular, while ensuring data consistency to restrict the foreign key. an index can affect DRI Constraint performance only for deleting a row or rows on the FK side. When using a constraint during insert or update, the processor knows the value of FK and must check for the presence of a row in the table referenced by the PK side. There is already an index. When deleting a row on the PK side, he must make sure that there are no rows on the FK side. In this case, the index may be slightly useful. But this is not a common scenario.
In addition, in some types of queries, while the query processor must find records on many sides of the connection that use this foreign key column. connection performance increases when an index exists for this foreign key. But this condition is typical for the use of the FK column in the join request, and not for the existence of a foreign key constraint ... It does not matter if the other side of the join is PK or just some other arbitrary column. Also, if you need to filter or order query results based on this FK column, the index will help ... Again, this has nothing to do with limiting the foreign key in this column.
Charles Bretana Nov 10 '08 at 20:35 2008-11-10 20:35
source share