PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 12th, 2012, 10:03 PM
Yue_Hong Yue_Hong is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 Yue_Hong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 15 sec
Reputation Power: 0
PHP-General - Improve Script Performance

Hi,

Recently I developed some webpage and I found that most of the part that slow down the execution of a php script is due to the mysql connection. When there are more mysql queries in the page, the whole page slow down a lot.

There was one web application that I developed having lots of query writing to the database which result in about 20 to 25 sec of execution. So, I reprogram it to make all result into an array and only store once into the database at the end of execution. This way the execution time decreased to less than 5 sec.

To bring a faster web application, I am thinking it's better to have mysql query (read or write) as minimal as possible. So I am thinking to have the query run once on the beginning of the script to get every data we needed for that whole execution and store into array. Have the rest of the query works with the array, filter the result from the array to get detail result. Anything that need to store to the database, will be stored in another array and will only write once to database on all of it at the end of the script.

Do you think it is a good idea for my above suggestion? Or is there any ready solid solution for this kind of general performance improvement issue?

Thanks.

Reply With Quote
  #2  
Old November 12th, 2012, 11:10 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,054 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 5 h 27 m 59 sec
Reputation Power: 7104
Reducing the number of queries you run is an important optimization step, but it's not necessary to run all of your reads at the beginning and all of the writes at the end. The time at which you run the query has no effect on performance, only the number of queries that you run (and the queries themselves of course) affect performance.

One thing you should almost never have in your scripts is queries inside loops; that is a key indicator that you should be using a join or better conditions instead.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old November 13th, 2012, 12:14 AM
Yue_Hong Yue_Hong is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 Yue_Hong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 15 sec
Reputation Power: 0
Thanks for your reply.

Is there any ready open-source framework that does the job as I describe above?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Improve Script Performance

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap