Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc

I’ve heard that SELECT * is generally bad practice to use when writing SQL commands because it is more efficient to SELECT columns you specifically need.

If I need to SELECT every column in a table, should I use

SELECT * FROM TABLE

or

SELECT column1, colum2, column3, etc. FROM TABLE

?

hi @ivan_s

I’d advice to use what is better understandable when reading the code.
For me select * is faster to understand when I’m reading code.
But it also will depend on many cases, like, will you add new columns in the future that you may not need in this query ? etc

I think for now this is an unnecessary micro optimization and pick whichever looks better to you.

My framework always creates a list of fields in the response. And I can optimize the request. Would it be better if I will optimize right away?

By optimize you mean you don’t need all columns ?
If you don’t, then request only those that you need.

Hi @ivan_s,
As a general rule of thumb, it is better to avoid scanning all columns of the table and instead just scan the columns that your application needs (using SELECT column1, column2..), for better query performance.
Additionally, it also makes sure that your application is not impacted if there are any changes to the table in future, like addition of new columns, or removal of unused columns.

Thanks! I also think that get all the columns is wrong.