-
Hi,
I've noticed that most SQL examples on this and other sites begin with Select * from ... even if only a few fields are needed.
Many moons ago I was taught to explicitly select only the fields that you wanted to retrieve as this would reduce the overhead required to perform the query and greatly increase the speed.
Is this still true?
Thanks,
Al.
-
Yes, but it's often easier in some situations to collect the entire set of fields. It's also not that different in time now, with todays processors. Although I still notice :).
-
I would say that it is mostly out of laziness. Usually we are trying to prove a point OTHER than how to select individual columns, and using a * instead of individual field names makes the statement easier to read.
In practice, select only the fields you need (but we all get lazy sometimes, and as always, there are trade-offs involved no matter what you do)
-
Laziness...Isn't that one of the virtues of a programmer?