Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc

后端 未结 30 3600
清歌不尽
清歌不尽 2020-11-21 23:59

I\'ve heard that SELECT * is generally bad practice to use when writing SQL commands because it is more efficient to SELECT columns you specificall

30条回答
  •  我在风中等你
    2020-11-22 00:34

    You should only select the columns that you need. Even if you need all columns it's still better to list column names so that the sql server does not have to query system table for columns.

    Also, your application might break if someone adds columns to the table. Your program will get columns it didn't expect too and it might not know how to process them.

    Apart from this if the table has a binary column then the query will be much more slower and use more network resources.

提交回复
热议问题