SyntaxStudy
Sign Up
MySQL Beginner 3 min read

Avoiding SELECT *

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.

Example
-- 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;
Pro Tip

SELECT * prevents covering indexes from being used, even if one exists.