Solved

Database Performance (MySQL) versus PHP Performance

Posted on 2011-03-05
4
396 Views
Last Modified: 2012-05-11
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
Comment
Question by:numberkruncher
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
Aaron Tomosky earned 250 total points
ID: 35044468
So small you won't know the difference. 100 rows is nothing. May as well just leave it in mysql.
0
 
LVL 13

Author Comment

by:numberkruncher
ID: 35044478
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
 
LVL 9

Assisted Solution

by:Vampireofdarkness
Vampireofdarkness earned 250 total points
ID: 35044507
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
 
LVL 13

Author Closing Comment

by:numberkruncher
ID: 35044516
Thanks for the input guys!
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now