Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Database Performance (MySQL) versus PHP Performance

Which of the following two options will perform the best (generally) where both MySQL and PHP are running on the same server?

Choice #1
Request 100 rows from a database table.

The database connection will have already been opened, I am only interested in the query performance itself.

Choice #2
Load a cached PHP script which includes the 100 rows (which are very rarely changed - if at all).
0
numberkruncher
Asked:
numberkruncher
  • 2
2 Solutions
 
Aaron TomoskyTechnology ConsultantCommented:
So small you won't know the difference. 100 rows is nothing. May as well just leave it in mysql.
0
 
numberkruncherAuthor Commented:
Really?

At the moment my pages are receiving between 8 and 10 queries per request. It is early stages and this quantity is likely to increase to up to 30 queries per request.

If the difference is minuscule then I shall just stick to a simple MySQL query.

Thanks, that helps give me perspective on who efficient MySQL is.
0
 
VampireofdarknessCommented:
These are things I often find myself wondering about. Cached vs not, enum 0/1 vs tinyint(1), etc...

I ran some tests on updating rows (x=1-x, x!=x and more) it takes something like 0.9 seconds to run 1,000 UPDATE queries on my home 'general use' PC. The difference between two was around 0.2 seconds, but that is still for 1,000 updates all happening at once so 0.0002 seconds per pass. I think I read somewhere it takes 30-40 (0.0400) milliseconds to blink, just to put it into perspective.  

In short, what aarontomosky said. 100 rows is nothing. Focus more on making your code bomb proof and functional.

If you're still in doubt, run some benchmarks. You'll be able to see the exact difference in milliseconds between the two (and it will be milliseconds if anything).
0
 
numberkruncherAuthor Commented:
Thanks for the input guys!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now