Skip to main content
added 357 characters in body
Source Link
J.D.
  • 39.5k
  • 12
  • 60
  • 134

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).

On top of all of that, as mentioned earlier in the comments, it's also cleaner code to specify the column list as opposed to using SELECT *. This is because it explicitly communicates which fields from the database are being consumed and helps establish the intent of the code, especially for developers who may not have access to the database itself.

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.

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.

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).

On top of all of that, as mentioned earlier in the comments, it's also cleaner code to specify the column list as opposed to using SELECT *. This is because it explicitly communicates which fields from the database are being consumed and helps establish the intent of the code, especially for developers who may not have access to the database itself.

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.

Typo.
Source Link
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 brakebreak 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.

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 brake 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.

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.

added 343 characters in body
Source Link
J.D.
  • 39.5k
  • 12
  • 60
  • 134

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 brokebrake 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.

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 even if no future schema changes ever broke 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'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 brake 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.

Source Link
J.D.
  • 39.5k
  • 12
  • 60
  • 134
Loading