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

后端 未结 30 3052
清歌不尽
清歌不尽 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:44

    In terms of execution efficiency I am not aware of any significant difference. But for programmers efficiency I would write the names of the fields because

    • You know the order if you need to index by number, or if your driver behaves funny on blob-values, and you need a definite order
    • You only read the fields you need, if you should ever add more fields
    • You get an sql-error if you misspell or rename a field, not an empty value from a recordset/row
    • You can better read what's going on.

提交回复
热议问题