0

When I was starting out I always just did SELECT * because I was afraid that if I messed around with the code in any way that I would cause an error...

Months later I realized that my website is full of SELECT *'s when a lot of the time I only need to select one column.

Will it make a noticeable difference in page load time if I reduce all the "SELECT *" to "SELECT column"?

I assume that it makes it faster, but I have no idea if it would be noticeable.

Thanks!

User007
  • 41
  • 7

2 Answers2

5

It depends on the amount of data that your table holds or the number of joins in your query. Definitely, select column will be faster than select *. But, the statistics absolutely depend on the data.

Also it is a bad practice. please see this question:

Why is SELECT * considered harmful?

Community
  • 1
  • 1
Manikandan Sigamani
  • 1,964
  • 1
  • 15
  • 28
0

Yes, it will be faster. (At the very least, you're sending less data between your RDBMS and whatever scripting language you have in use.)

As to how much faster, it really depends on the amount of fields/data, etc. in your database. As such, you'll need to profile your application in both states to find out. (As the old saying goes - why estimate what you can measure?)

Incidentally, I'd also recommend a read of the existing What is the reason not to use select *? question/answers.

Community
  • 1
  • 1
John Parker
  • 54,048
  • 11
  • 129
  • 129