1
SQLAdvanced#scaling
Read the execution plan, index the columns used in WHERE/JOIN/ORDER BY, select only needed columns, avoid functions on indexed columns, replace correlated subqueries with joins, and paginate large result sets.
-- before SELECT * FROM orders WHERE LOWER(email) = 'a@b.com'; -- after CREATE INDEX idx_email_lower ON orders (LOWER(email)); SELECT id, total FROM orders WHERE LOWER(email) = 'a@b.com';