|
|
|
|
|
by dragonwriter
3339 days ago
|
|
> Once you have an FK, you're going to want to query against it. Not necessarily. You are definitely (at a minimum, implicitly for referential integrity) going to want to query from the table using the FK to the table it references, but you may or may not want to query by the FK column. > Come up with an example of an FK you never want to join on and then maybe we talk about not wanting an FK indexed. Joining on an FK doesn't require the FK to be indexed, it requires the target to be indexed. You need an index on the FK of the FK is used in a simple equality or inequality filter criteria other than a join to it's target, or if it's used in a join where the other criteria are filtering it's target table rather than the table with the FK. But if you filter the table with the FK and join to it's target, which is a fairly common case, you don't need an FK index. |
|