Problem Statement
Why should you index foreign key columns in large OLTP tables?
Explanation
When a parent row changes or is deleted, the engine must find matching children. An index on the child foreign key avoids full scans and reduces lock time.
It also makes child-to-parent joins fast in day-to-day queries.
Code Solution
SolutionRead Only
CREATE INDEX idx_orders_customer_id ON orders(customer_id);
Practice Sets
This question appears in the following practice sets:
