select - Is selecting all columns from a SQL table expensive? -


this question has answer here:

is expensive select columns sql table, compared specifying columns retrieve?

select * table 

vs

select col1, col2, col3 table 

might useful know of tables i'm querying have on 100 columns.

it may be. depends on indexes defined on table.

if there's non-clustered index on col1,col2,col3 index may used satisfy query (since it's narrower table itself, heap or clustered index), should result in lower i/o costs.

it's also, generally, preferred can determine queries using particular columns in table.

if table has no indexes, or single clustered index, or there no indexes cover particular query, every page of heap/clustered index going have accessed anyway. then, if have off-row data (e.g. largish varchar(max)) then, if don't include column in select can avoid that i/o cost.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -