Solved

Database Performance (MySQL) versus PHP Performance

Posted on 2011-03-05
4
402 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

895 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

16 Experts available now in Live!

Get 1:1 Help Now