Join columns are prime indexing candidates.
Section: Join performance
Index join keys
sql
sql
CREATE INDEX idx_orders_customer_id ON orders(customer_id);
CREATE INDEX idx_line_items_order_id ON line_items(order_id);Explanation
Indexes on foreign keys and matching join columns reduce scans and nested-loop pain.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Join performance
Use EXPLAIN to inspect join strategy
Check whether the planner uses indexes, hash joins, merge joins, or nested loops.
Reduce row counts before large joins
Filter or aggregate early when possible.