How many queries are too many?

前端 未结 8 1179
暗喜
暗喜 2021-01-01 12:47

I have to run one time 10 mysql queries for one person in one page. Is it very bad? I have quite good hosting, but still, can it break or something? Thank you very much.

8条回答
  •  伪装坚强ぢ
    2021-01-01 13:19

    Just to add a bit of a different perspective to the other good answers:

    First, to concur, the type and complexity of queries you are making will matter more 99% of the time than the number of queries.

    However, in the rare situation where there is high latency on the network path to your database server (i.e. the db server is remote or such, not saying this is a logical or sane setup, but I have seen it done) then you want to minimize the number of queries done, because every single time you talk to the database server the network transmission time will take an order of magnitude or two longer than it takes to compute the query. This situation can really kill your page loading times, and so you'd really want to minimize the number of queries (actually, you just want to change your server setup...).

提交回复
热议问题