You made one comment which is caught my attention:

> that's a no go :(  Or is there a way of storing common query results?

If the results to a commonly called query are the same for a time period,
than why don't you right a routine that just stores the results into a new
database that also has a results_expired field.  Then, everytime the results
are request, you can write a function which checks to see if the results are
still valid, if they are, it displays them, if not, it requeries...


function getresults($common_query)
  $query="SELECT results,TIMESTAMP(expired) as dt_expired FROM storedqueries
WHERE query=$common_query";
  $results=mysql_fetch_object(mysql_query($query)) or error_handler();
  if($results->expired <=time())
    //rebuild long slow query and exectue it so that $results has the result
of the new query and $query is the query
   $update_query="INSERT INTO storedqueryies (query,results,expired) VALUES
   mysql_query($update_query) or error_handler();

  return $results->results;

-----Original Message-----
From: John Holmes [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, July 24, 2002 6:49 PM
To: 'Richard Baskett'; 'PHP General'
Subject: RE: [PHP] Speeding up PHP or MySQL

> Is there anyways to speed up MySQL queries?  Or showing the results 
> through PHP? I have several queries that have about 8 left joins or 
> so.. Yes
> huge and when you have lots of people using these functions at once it 
> really slows down.. Are there any practices that you can think of that 
> would speed up any sql queries?  I was thinking of using stored 
> procedures,
> after a bit of research I found ou= t that MySQL doesn=B9t have that
> so
> that's a no go :(  Or is there a way of storing common query results?
> am
> looking for _anything_ that will speed up showing results to large 
> queries..

How about an index on your tables?

---John Holmes...

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to