Darghon Posted November 16, 2012 Share Posted November 16, 2012 (edited) Hi all, Not sure where to post my problem, so I hope I'll get some answers here. I have a basic LAMP setup. All works fine have APC installed tweaked somewhat with mysql cache sizes etc now I have 1 pageload in my application that takes +- 10 seconds to complete, and I can't seem to find out why... What I checked: I used firebug net view to see howlong the request takes, and it takes an average of 10 seconds, and is 25kb large (the response) xdebug on the server tells me that the request start to finish takes 2442ms (2.4s) (the request load is measured with xdebug off, if it's turned on the request takes 24+ seconds to complete...) what am I missing? why is that specific page request taking 10 seconds while the server sais it's done in 2.4. The page doesn't contain a lot of javascript, so that's ruled out... any other areas I can check? or does anyone else have an idea where the delay is located? Edited November 16, 2012 by Darghon Quote Link to comment https://forums.phpfreaks.com/topic/270781-php-performance-issues/ Share on other sites More sharing options...
kicken Posted November 16, 2012 Share Posted November 16, 2012 Executing SQL queries in a loop is a fairly common cause of slow pages. For example doing something like: $res=mysql_query('SELECT blah FROM bleh'); while ($row=mysql_fetch_assoc($res)){ $res2=mysql_query('SELECT foo FROM boo WHERE blah='.$row['blah']); } The only way to find out what is going on really though is to profile the script to see what exactly is taking up the time. If your PHP script seems to be running about as quick as possible but it still takes a long time for the page to render, you'll need to use browser dev tools like firebug or chrome's console to analyze where the time is being spent (loading resources such as scripts, parsing the dom, applying css, etc). Quote Link to comment https://forums.phpfreaks.com/topic/270781-php-performance-issues/#findComment-1392897 Share on other sites More sharing options...
Darghon Posted November 16, 2012 Author Share Posted November 16, 2012 Executing SQL queries in a loop is a fairly common cause of slow pages. For example doing something like: $res=mysql_query('SELECT blah FROM bleh'); while ($row=mysql_fetch_assoc($res)){ $res2=mysql_query('SELECT foo FROM boo WHERE blah='.$row['blah']); } The only way to find out what is going on really though is to profile the script to see what exactly is taking up the time. If your PHP script seems to be running about as quick as possible but it still takes a long time for the page to render, you'll need to use browser dev tools like firebug or chrome's console to analyze where the time is being spent (loading resources such as scripts, parsing the dom, applying css, etc). Well the 2 points in the end are basicly the things I've checked so... and I indeed have nested statements etc, but I have to. otherwise I won't be able to process my business rules that I have specified for each table/object. anyway, I managed to solve the issue. The cachegrind result was wrong basicly, and the request was taking 4x longer than reported. I tinkered somewhat with the loaded statements, and cached them inside the objects that called them, resulting in a speed gain. request now takes 3 seconds to load into the browser, and I'm happy with the results. Quote Link to comment https://forums.phpfreaks.com/topic/270781-php-performance-issues/#findComment-1392921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.