php - Are include()s faster or database queries? -


A client is requesting that we store some important and complex configuration data as PHP arrays, while I I want to store it in the database. He highlighted the issue of efficiency / optimization, which states that the file is much faster than the I / O database queries. I am pretty sure that I have heard that anywhere in the file which is actually slow in PHP.

Any statistics on this / real information?

I do not think that performance is an attractive argument or there is no way. On my Mac, I run the following tests.

The first 10,000 contains a file that does not do anything but sets one variable:

   

It took 58 seconds to run each time. (Remember, that is also included in 10,000.)

Then I wrote another script, which asks the database 10,000 times. It does not select any actual data, just a SELECT NOW () does.

  & lt ;? Php mysql_connect ('127.0.0.1', 'root', ''); Mysql_select_db ('test'); $ Mtime = microtime (); $ Mtime = explosion ('', $ mtime); $ Mtime = $ mtime [1] + $ mtime [0]; $ Starting = $ mtime; ($ I = 0; $ i & lt; 10000; $ i ++) {mysql_query ("Choose Now ()"); } $ Mtime = microtime (); $ Mtime = Explosion ("", $ mtime); $ Mtime = $ mtime [1] + $ mtime [0]; $ Endtime = $ mtime; $ Totaltime = ($ endtime - $ start time); Copy 'Presented In' $ Totals 'seconds.'; ? & Gt;  

This script takes approximately 0.76 seconds to run on my computer. I obviously there are many factors that make a difference in your specific case, but creating a MySQL query makes it easy to run Performance difference is not. (Note that I did not include mysql connection overhead in my test - if you are connected to get data only in the database, then it will make a difference.)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -