Forum Moderators: coopster

Message Too Old, No Replies

Why is my php/query slow first time, but not second?

         

brandon0401

4:10 am on Mar 7, 2008 (gmt 0)

10+ Year Member



$res1=mysql_query('select id, feed_title, feed_detail, feed_image, pub_date from link_feeds where rss_id=' . $id . ' order by id desc' . $nrec . '');

which query turns into:
select id, feed_title, feed_detail, feed_image, pub_date from link_feeds where rss_id=249 order by id desc limit 0,8

On first load on page I get slow time...

after
$res1=mysql_query('select id, feed_title, feed_detail, feed_image, pub_date from link_feeds where rss_id=' . $id . ' order by id desc' . $nrec . '');
=
Processed:0.393Memory:389920

other queries, few diff stuff after, final total loading time for box
all the way through the while($row1=mysql_fetch_assoc($res1))

with above time is

=
Processed:0.395Memory:389920

----

there is about 16 diff boxes so it matters...

If you refresh the page they all load in .001...I do the query by itself always get .001 or less....

What am I doing wrong? Thanks.

jatar_k

1:15 pm on Mar 7, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hard to say, what else is happening before the query

a query is executed the same way every time the page is loaded

if on first load your page is slow and every subsequent refresh is fast then you would think something is being cached on the first load, the query is probably not the culprit.

Maybe a look at images, external files or anything else that is cached by the browser. You could try doing a full reload every time by using ctrl+f5 and see if then it is always slow.

You've also partly discounted the query as being the issue since the query seems to be very fast.

brandon0401

5:56 pm on Mar 13, 2008 (gmt 0)

10+ Year Member



$res1=mysql_query('select id, feed_title, feed_detail, feed_image, pub_date from link_feeds where rss_id=' . $id . ' order by id desc' . $nrec . '');

its this query/part that takes a long time, about half a second....second time ran its .00005

which is
select id, feed_title, feed_detail, feed_image, pub_date from link_feeds where rss_id=249 order by id desc limit 0,8