PHP rendering

PHP rendering

am 09.02.2007 16:27:31 von Harpreet

I have a sql query which takes like 6 seconds to return results when run
in query analyzer but when used via a php webpage to display in a report
it take over 15 seconds.

What can be the reason for the page to take so long to return results.

Any help is appreciated.

Thanks
Harpreet Kaur

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP rendering

am 09.02.2007 16:37:47 von Phillip Terry

If the query analyzer runs directly on the server, it would probably be
faster than the extra steps required by php to query for and render out the
data through a browser, especially if its on a shared server, but 9 seconds
of difference does seem like a lot.


----- Original Message -----
From: "Harpreet"
To:
Sent: Friday, February 09, 2007 9:27 AM
Subject: [PHP-WIN] PHP rendering


I have a sql query which takes like 6 seconds to return results when run
in query analyzer but when used via a php webpage to display in a report
it take over 15 seconds.

What can be the reason for the page to take so long to return results.

Any help is appreciated.

Thanks
Harpreet Kaur

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP rendering

am 09.02.2007 17:27:14 von Jarrett Meyer

You may want to try a few things. (1) All queries are run inside funct=
ions. I don't do any work inside (2) These functions are always called=
from a wrapper function, which includes reporting the time to run just the=
query. =0AGetOrderNumber(MyOrderNumber, &$DS_Order)=0A{=0A global =
$QueryTimers;=0A $QueryStartTimer =3D microtime();=0A $Sql =3D "SELEC=
T **** FROM orders WHERE OrderNumber =3D " . MyOrderNumber;=0A $Result =
=3D mysql_query( $Sql );=0A $QueryEndTimer =3D microtime();=0A $Query=
Timers[] =3D $QueryEndTimer - $QueryStartTimer;=0A =0A // check for a=
nd handle errors gracefully=0A // return false if there are any problems=
=0A // return true if successful=0A} output code=0A.... $QueryTimer=
s =3D array();=0A.... code here ....=0A.... GetOrderNumber(MyOrderNumber);=
=0A.... more code .... =0AThen, at the bottom of my pages, in a footer=
file, I have output along the lines of "total query time =3D 0.15s (2 quer=
ies) // total page loading =3D 3.21s". This helps me know efficient my page=
s are. This will give you an idea of what is taking so long. My work i=
s all on a company intranet, so I don't have a problem with displaying thes=
e values. Your mileage may vary. As far as getting queries to run fast=
er... (a) I have found that it can be much faster to have multiple que=
ries instead of overly complicated joins. Although not too bad with inner j=
oins, your left, right, and Cartesian joins can be big resource hogs. =
(b) Look at your selection criteria. You want to put the selection criteria=
that will eliminate the most data first in the WHERE clause. (c) Avoi=
d using "SELECT *...". Your queries will be faster if you select the specif=
ic columns that you want, even if you want all columns in a particular tabl=
e.=0A =0AThank you,=0AJarrett No trees were harmed during this transmi=
ssion; however, several electrons were terribly inconvenienced. ----- =
Original Message ----=0AFrom: Harpreet =0ATo: php=
-windows@lists.php.net=0ASent: Friday, February 9, 2007 10:27:31 AM=0ASubje=
ct: [PHP-WIN] PHP rendering I have a sql query which takes like 6 seco=
nds to return results when run=0Ain query analyzer but when used via a php =
webpage to display in a report=0Ait take over 15 seconds. What can be =
the reason for the page to take so long to return results. Any help is=
appreciated. Thanks=0AHarpreet Kaur --=0APHP Windows Mailing Lis=
t (http://www.php.net/)=0ATo unsubscribe, visit: http://www.php.net/unsub.p=
hp

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php