Re: [PHP] my php script is very slow. help?
If you are using DB queries a lot, try to use LIMIT, this will save lot of your time. Tom Carter wrote: > Do you have many DB queries? What is the average size of the result > returned? > > have you tried running timing functions on it to get a measure of how long > the page is taking? theres many examples on the web.. > > You can also use these to calculate the time for different sections.. that > should help you work out what is taking the time. > > HTH,Tom > >> >> Hi all >> >> I have Linux/PHP/MySQL. Some of my script really run >> very slowly. painfully slow. All data are fetched from >> the database. The tables in database are indexed. >> Still some scripts are very slow. I am using nested >> while and for loops. Any idea how to make them faster? >> >> What should I avoid in my scripting? >> >> thanks all >> >> >> Do You Yahoo!? >> Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk >> or your free @yahoo.ie address at http://mail.yahoo.ie >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> To contact the list administrators, e-mail: [EMAIL PROTECTED] >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] my php script is very slow. help?
If you're only doing one DB query per page, then the query is probably what's taking the longest. Log into mysql, and execute EXPLAIN SELECT ... ... It'll tell you how MySQL plans on performing the query across the rows of the table(s). You can use the information it provides to optimize your tables and/or indicies. See this section of the MySQL manual for more info: http://www.mysql.com/doc/E/X/EXPLAIN.html -Original Message- From: Tom Carter [mailto:[EMAIL PROTECTED]] Sent: Friday, July 27, 2001 6:48 AM To: hassan xaaji; [EMAIL PROTECTED] Subject: Re: [PHP] my php script is very slow. help? Do you have many DB queries? What is the average size of the result returned? have you tried running timing functions on it to get a measure of how long the page is taking? theres many examples on the web.. You can also use these to calculate the time for different sections.. that should help you work out what is taking the time. HTH,Tom > > > Hi all > > I have Linux/PHP/MySQL. Some of my script really run > very slowly. painfully slow. All data are fetched from > the database. The tables in database are indexed. > Still some scripts are very slow. I am using nested > while and for loops. Any idea how to make them faster? > > What should I avoid in my scripting? > > thanks all > > > Do You Yahoo!? > Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your > free @yahoo.ie address at http://mail.yahoo.ie > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] To > contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] my php script is very slow. help?
Be careful with any sort of nested loops. You may not be able to avoid them, but if you nest a while loop within another while loop, and simply iterate through results, you will have quadratic running time. This isn't a big deal if you've got 20 results, but for every increase in N (size of result) your running time will increase N^2. So, if you've got a large dataset, the process time will be enormous. Jack -Original Message- From: hassan xaaji [mailto:[EMAIL PROTECTED]] Sent: Friday, July 27, 2001 5:51 AM To: [EMAIL PROTECTED] Subject: [PHP] my php script is very slow. help? Hi all I have Linux/PHP/MySQL. Some of my script really run very slowly. painfully slow. All data are fetched from the database. The tables in database are indexed. Still some scripts are very slow. I am using nested while and for loops. Any idea how to make them faster? What should I avoid in my scripting? thanks all Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] my php script is very slow. help?
Do you have many DB queries? What is the average size of the result returned? have you tried running timing functions on it to get a measure of how long the page is taking? theres many examples on the web.. You can also use these to calculate the time for different sections.. that should help you work out what is taking the time. HTH,Tom > > > Hi all > > I have Linux/PHP/MySQL. Some of my script really run > very slowly. painfully slow. All data are fetched from > the database. The tables in database are indexed. > Still some scripts are very slow. I am using nested > while and for loops. Any idea how to make them faster? > > What should I avoid in my scripting? > > thanks all > > > Do You Yahoo!? > Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk > or your free @yahoo.ie address at http://mail.yahoo.ie > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] my php script is very slow. help?
If your Database is big, avoid loops which goes to whole the DB. This is just one thought. DT - Original Message - From: "hassan xaaji" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 27, 2001 15:36 Subject: [PHP] my php script is very slow. help? > > > Hi all > > I have Linux/PHP/MySQL. Some of my script really run > very slowly. painfully slow. All data are fetched from > the database. The tables in database are indexed. > Still some scripts are very slow. I am using nested > while and for loops. Any idea how to make them faster? > > What should I avoid in my scripting? > > thanks all > > > Do You Yahoo!? > Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk > or your free @yahoo.ie address at http://mail.yahoo.ie > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]