Why is using SELECT * generally discouraged in production queries?
Last updated
SELECT * fetches every column, which wastes I/O and network, defeats index-only plans, and makes queries fragile to schema changes. Naming columns explicitly is clearer and safer in production.
Performance cost:
Reads and transfers columns you don't need, including large text/blob fields.
Prevents covering-index optimizations, forcing extra lookups to the base table.
Fragility:
Column additions/reordering can break code relying on position or shift result shape.
Ambiguous or duplicate column names in joins.
Clarity: Explicit lists document exactly what a query depends on.
Acceptable uses: Ad-hoc exploration or
EXISTS (SELECT * ...), where the projection is never materialized.
- https://maciejadamski.com/blog/no-select-star/
- https://dev.to/pawsql/9-reasons-to-avoid-using-select-and-2-exceptional-cases-57
- https://dev.to/chiragx309/the-sql-query-that-nearly-crashed-our-production-server-51i8
- https://medium.com/learning-sql/why-you-should-avoid-using-select-in-sql-uncovering-the-hidden-costs-21bfc5b17560
- https://stevesohcot.medium.com/skip-the-asterisk-why-select-is-slowing-down-your-sql-queries-6bb8b2e4ea4d
- https://tanelpoder.com/posts/reasons-why-select-star-is-bad-for-sql-performance/