Liran Ben Yehuda
Liran Ben Yehuda

Reputation: 1588

SQL SELECT clause tuning

Why does the sql query execute faster if I use the actual column names in the SELECT statement instead of SELECT *?

Upvotes: 2

Views: 568

Answers (4)

Naga
Naga

Reputation: 1

Its possible the performance is way better when you select certain column names than Select *, one good reason, just check whether, you have used the columns which are already indexed, in this case, the optimizer will make a plan to select all the data only from index instead from actual table. But check the plan once for sure.

Upvotes: 0

Tim
Tim

Reputation: 1559

A noticeable difference at all seems odd... since I'd expect it to be a very minuscule difference and am intrigued to test it out.

Any difference might in a statement using Select * might be due to it taking extra time to find out what all of the column names are.

Upvotes: 5

Billy Moon
Billy Moon

Reputation: 58619

Generally, the more you tell it, the less it has to calculate. This is the same for many systems.

Upvotes: 1

BugFinder
BugFinder

Reputation: 17868

Because depending on the query it has to work out if there are unique names, what they all are, etc. Where as, if you specificy it, its all done for it.

Upvotes: 3

Related Questions