Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql select query taking over 8 seconds yet limit is 5 records
    text
    copied!<p>following the answers i got on this thread <a href="https://stackoverflow.com/questions/4011071/php-mysql-query-to-get-most-popular-from-two-different-tables/4536472#4536472">PHP MySQL Query to get most popular from two different tables</a></p> <p>ive timed the query and im getting disturbing times when calling this query. I get over 8 seconds. afrostarvideos table has about 2000 records,afrostarprofiles about 300records. even after limiting the query to only five. goto <a href="http://www.veepiz.com/index.php" rel="nofollow noreferrer">http://www.veepiz.com/index.php</a> and check this generation time under popular artists. Please help optimize this query</p> <pre><code>//Get current time $mtime = microtime(); //Split seconds and microseconds $mtime = explode(" ",$mtime); //Create one value for start time $mtime = $mtime[1] + $mtime[0]; //Write start time into a variable $tstart = $mtime; $q= "SELECT `p`.*, SUM(`v`.`views`)+`p`.`views` AS `totalViews` FROM `afrostarprofiles` `p` LEFT OUTER JOIN `afrostarvideos` `v` ON `p`.`id` = `v`.`artistid`". "GROUP BY `p`.`id` ORDER BY SUM(`v`.`views`)+`p`.`views` DESC LIMIT $pas_start,$end"; $r=mysql_query($q); //Get current time as we did at start $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; //Store end time in a variable $tend = $mtime; //Calculate the difference $totaltime = ($tend - $tstart); //Output result printf ("Page was generated in %f seconds !", $totaltime); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload