Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • article content and info
  • IF the author is a registered user, their info
  • UPDATE the article's view counter
  • retrieve comments on the article
  • retrieve information for the authors of the comments
  • if the reader of the article is signed in, query for info on them
  • etc...

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?

like image 702
johnnietheblack Avatar asked Feb 18 '09 16:02

johnnietheblack


1 Answers

As many as needed, but not more.

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.

like image 114
Piskvor left the building Avatar answered Oct 25 '22 22:10

Piskvor left the building