Which is faster / more efficient - lots of little MySQL queries or one big PHP array?

前端 未结 6 1010
离开以前
离开以前 2021-02-06 01:55

I have a PHP/MySQL based web application that has internationalization support by way of a MySQL table called language_strings with the string_id,

6条回答
  •  孤城傲影
    2021-02-06 02:16

    OK - I did some benchmarking and was surprised to find that putting things into an array rather than using individual queries was, on average, 10-15% SLOWER.

    I think the reason for this was because, even if I filtered out the "uncommon" elements, inevitably there was always going to be unused elements as a matter of course.

    With the individual queries I am only ever getting out what I need and as the queries are so simple I think I am best sticking with that method.

    This works for me, of course in other situations where the individual queries are more complex, I think the method of storing common data in an array would turn out to be more efficient.

提交回复
热议问题