Why is SELECT * considered harmful?

后端 未结 15 1478
野的像风
野的像风 2020-11-21 04:12

Why is SELECT * bad practice? Wouldn\'t it mean less code to change if you added a new column you wanted?

I understand that SELECT COUNT(*)

15条回答
  •  無奈伤痛
    2020-11-21 05:00

    Selecting with column name raises the probability that database engine can access the data from indexes rather than querying the table data.

    SELECT * exposes your system to unexpected performance and functionality changes in the case when your database schema changes because you are going to get any new columns added to the table, even though, your code is not prepared to use or present that new data.

提交回复
热议问题