php: sessions vs. database

后端 未结 3 907
太阳男子
太阳男子 2021-01-05 05:44

I have a class that retrieves its memeber (more or less 10 members) from a database.

My question is: is it more efficient to fetch them every time from the db (MySQL

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-05 06:12

    Depends what you mean by 'efficient'. One's time-efficient, one's disk-space-efficient. And it's very difficult to judge the two against each other, unless your requirements are at either extreme end of the spectrum. You'd probably do OK just flipping a coin, measuring performance over time, and adjusting based on any observed problems.

    Premature optimisation is the root of all evil.

提交回复
热议问题