What is the reason not to use select *?

后端 未结 20 2805
独厮守ぢ
独厮守ぢ 2020-11-21 07:14

I\'ve seen a number of people claim that you should specifically name each column you want in your select query.

Assuming I\'m going to use all of the columns anyway

20条回答
  •  我寻月下人不归
    2020-11-21 07:51

    If your code depends on the columns being in a specific order, your code will break when there are changes to the table. Also, you may be fetching too much from the table when you select *, especially if there is a binary field in the table.

    Just because you are using all the columns now, it doesn't mean someone else isn't going to add an extra column to the table.

    It also adds overhead to the plan execution caching since it has to fetch the meta data about the table to know what columns are in *.

提交回复
热议问题