0

My chief architect at work is a genius and I've learned so much from him, but he doesn't agree with NOT using SELECT * in our application queries.

His reason is that it doesn't matter much when you're pulling 10 rows, we end pulling 100+ columns just to show 4 to the user.

He's open to discussion which is great and that's why I'm looking online for resources that display hard evidence on SQL query times or something along those lines to present to him.

And, I'm also looking for a way to track those statistics in my app without using up too much CPU (we use .NET 4.0 framework). Thanks for your help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
fwhenin
  • 473
  • 5
  • 13
  • This question may be better suited for http://programmers.stackexchange.com/ – p.s.w.g Jun 29 '13 at 15:58
  • 1
    See: [Bad habits to kick: using SELECT * / omit the column list](https://sqlblog.org/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list) – marc_s Jun 29 '13 at 15:58
  • 3
    Why don't you benchmark the two and compare the results? – Nasreddine Jun 29 '13 at 15:59
  • 1
    possible duplicate of [Why is SELECT \* considered harmful?](http://stackoverflow.com/questions/3639861/why-is-select-considered-harmful) – Nasreddine Jun 29 '13 at 16:01
  • do you mean, if we need 10 column out of 100, use select *? –  Jun 29 '13 at 16:01
  • The answer is .... it depends. – shahkalpesh Jun 29 '13 at 16:06
  • I think the main argument against the use of the `*` wildcard column in SQL is not really one of performance but that its use makes it harder to figure out what went wrong after the table layouts have subtly changed. – 500 - Internal Server Error Jun 29 '13 at 18:38
  • In SQL server, when you create indexes, you can have the index include extra columns cached along side the indexed columns - the indexed columns make it easy to satisfy `where` clauses and the 'included' columns make it easy to satisfy `from` clauses. If you need to select columns that aren't in the index, it has to go to the primary key index (if one exists) or scan through the entire table if no suitable index exists to find the other columns. `SELECT *` kills index hitrates and circumvents non-clustered indexes. – antiduh Jun 30 '13 at 02:39

1 Answers1

1

How about putting together a table with several columns varbinary(max) containing a few large files...and execute the query remotely..

dougajmcdonald
  • 19,231
  • 12
  • 56
  • 89