Skip to main content
3 of 4
Typo.
Phill W.
  • 9.5k
  • 1
  • 12
  • 22

There's a third option you forgot to mention, make one DB call, with SELECT COLUMN_LIST. The reason I mention this is because the comparison of when to use SELECT * vs SELECT COLUMN_LIST isn't really about how many database calls one makes, rather it's about schema consistency.

The reason SELECT * is recommended against is because the schema of the dataset you're selecting from is liable to change over time, which could result in unexpected outcomes and errors, especially on your application as the consumer which is always expecting Column1 to be Column1, and Column3 to be the third column, etc.

And even if no future schema changes ever break the application, you still can run into performance issues as well with using SELECT *, for two reasons. One being that there may have been additional columns added to the end of the dataset which you're now needlessly bringing back extra data for. The second reason is you'll potentially cause a less than optimal query plan to be generated (e.g. an index that normally could be seeked on may not be applicable now).

There are a multitude of other reasons as well, but those are the few important ones that come to mind. Conversely, there are a few edge cases where it is OK to use SELECT * as opposed to an explicit column list, and you can find some of those examples in a similar question I asked here.

J.D.
  • 39.5k
  • 12
  • 60
  • 134