Avoid SELECT *
Selecting only the columns you need reduces network traffic, memory usage, and prevents covering index misses. Always list explicit columns in production queries.
Selecting only the columns you need reduces network traffic, memory usage, and prevents covering index misses. Always list explicit columns in production queries.
-- Bad: fetches all columns including large BLOBs
SELECT * FROM products WHERE category_id = 5;
-- Good: fetch only what the application needs
SELECT id, name, price, stock
FROM products
WHERE category_id = 5;
SELECT * prevents covering indexes from being used, even if one exists.