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

后端 未结 30 3471
清歌不尽
清歌不尽 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条回答
  •  萌比男神i
    2020-11-22 00:50

    One reason that selecting specific columns is better is that it raises the probability that SQL Server can access the data from indexes rather than querying the table data.

    Here's a post I wrote about it: The real reason select queries are bad index coverage

    It's also less fragile to change, since any code that consumes the data will be getting the same data structure regardless of changes you make to the table schema in the future.

提交回复
热议问题