Published: • 3 min read

Stop Using SELECT *

Table of Contents

SELECT * feels convenient, even liberating. No need to type out a dozen columns, no chance of missing one, just grab everything. But this shorthand comes at a heavy cost if you care about performance, maintainability, and sanity.

Why you shouldn’t use it

First, it encourages laziness in design. You’re telling the database to hand you every single column, even if your application or report only needs two or three. This leads to more data sent over the wire, more memory consumption on both the server and client, and wasted CPU cycles parsing and processing columns you don’t use. In production systems, this overhead compounds fast, especially under heavy concurrency.

Second, it breaks contracts. If you write SELECT *, your application implicitly depends on the order and presence of all columns in the table. Tomorrow, a developer adds a new column (say, isArchived), and suddenly your code breaks because column indexes shifted or your mapping logic misfires. By far I notice this the most in archiving code. Explicitly listing columns makes your code more robust against schema drift and makes it clear to other developers and yourself which fields matter.

Third, it decreases security and exposes you to accidental data leaks. Maybe you add a sensitive column later, like ssn or salary. If the query is still using SELECT *, you’re suddenly fetching and potentially exposing sensitive data to logs, UI, or external systems without realizing it.

Why you might use it

There are cases where SELECT * is fine. Ad hoc analysis, quick one-off scripts, or EXISTS checks where no data gets returned (SELECT TOP 1 * FROM table WHERE condition). But once a query leaves the realm of debugging and enters shared codebases or production ETL jobs listing columns explicitly is the only responsible choice.

Ultimately, SELECT * is a sign of short-term thinking. You trade a few seconds of typing for a long tail of technical debt and potential bugs. If you care about clarity, predictability, and performance, write out your columns. It’s boring. It’s tedious. It’s also the right thing to do.

Drake Hotline Bling meme