Does the number of columns returned affect the speed of a query?

前端 未结 18 2106
既然无缘
既然无缘 2020-12-10 16:27

If I have two queries

SELECT Id, Forename, Surname
FROM Person
WHERE PersonName Like(‘%frank%’)

And

SELECT *
FROM Person
WH         


        
18条回答
  •  感动是毒
    2020-12-10 16:43

    SELECT * will be slower since it has to transfer more data. Also because of some other reasons already mentioned. It really becomes a problem when joining tables since you start adding many more columns, when really all you want to do is join so you can filter.

    If you really want to use * , specify the table you want all the columns from, like SELECT Person.* FROM Person...

    That will narrow down the amount of data returned and makes it a little more readable.

提交回复
热议问题