Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance issue in using SELECT *? [duplicate]

Possible Duplicate:
Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc
What is the reason not to use select *?

Is there any performance issue in using SELECT * rather than SELECT FiledName, FiledName2 ... ?

like image 765
ecleel Avatar asked Jan 28 '09 13:01

ecleel


People also ask

Why SELECT * is not recommended?

Avoid using SELECT * There are many reasons for that recommendation, like: SELECT * Retrieves unnecessary data besides that it may increase the network traffic used for your queries. When you SELECT *, it is possible to retrieve two columns of the same name from two different tables (when using JOINS for example).

Why should you not use SELECT * in SQL?

When you use select * you're make it impossible to profile, therefore you're not writing clear & straightforward code and you are going against the spirit of the quote. select * is an anti-pattern. So selecting columns is not a premature optimization.

Does SELECT distinct affect performance?

Yes, the application needs to compare every record to the "distinct" records cache as it goes. You can improve performance by using an index, particularly on the numeric and date fields.

Is SELECT * slower than SELECT column?

But BLOBS are stored separately and only reference is available with row data. Selecting distinct and less than all columns will always be faster than selecting *.


1 Answers

Take a look at this post:

What is the reason not to use select *?

and these:

  • Performance benefit when SQL query is limited vs calling entire row
  • Which is faster or best, select * or select column1 colum2 column3
  • SQL query question select * from view or select col1 col2 col3 from view
  • Which is faster, select * or select column1 column2 etc
like image 128
Fred Avatar answered Oct 21 '22 19:10

Fred