select - Is selecting all columns from a SQL table expensive? -
this question has answer here:
- what reason not use select *? 20 answers
- select * vs select column 12 answers
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
Post a Comment