我应该限制自己在一个页面上进行几个MySQL查询?的PHP/MySQL的 [英] How many MySQL queries should I limit myself to on a page? PHP / MySQL
问题描述
好的,所以我敢肯定,你们中的许多人已经建立了疯狂的数据库密集型页面...
Okay, so I'm sure plenty of you have built crazy database intensive pages...
我正在构建一个页面,我想从中提取各种不相关的数据库信息.这是此页面的一些示例不同查询:
I am building a page that I'd like to pull all sorts of unrelated database information from. Here are some sample different queries for this one page:
- 文章内容和信息
- 如果作者是注册用户,则其信息
- 更新文章的视图计数器
- 检索对文章的评论
- 获取评论作者的信息
- 如果文章的读者已登录,请查询有关他们的信息
- 等...
我知道这些基本上很快就可以实现,并且我可以结合一些;但是我想确保这不是异常吗?
I know these are basically going to be pretty lightning quick, and that I could combine some; but I wanted to make sure that this isn't abnormal?
您将自己限制在一个页面上多少个正常且繁重的查询?
How many fairly normal and un-heavy queries would you limit yourself to on a page?
推荐答案
根据需要,但不多.
真的:不用担心优化(现在).首先构建它,然后测量性能,然后 IFF 在某处存在性能问题,然后从优化开始.
Really: don't worry about optimization (right now). Build it first, measure performance second, and IFF there is a performance problem somewhere, then start with optimization.
否则,您可能会花费大量时间来优化不需要优化的内容.
Otherwise, you risk spending a lot of time on optimizing something that doesn't need optimization.
这篇关于我应该限制自己在一个页面上进行几个MySQL查询?的PHP/MySQL的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!