Mysql select sorgusu 8 saniye devralarak henüz sınırı 5 kayıttır

0 Cevap php

Ben bu konu üzerinde var cevapları aşağıdaki PHP MySQL Query to get most popular from two different tables

ive sorgu ve bu sorgu çağrılırken rahatsız kez elde im zaman aşımına. Ben 8 saniye içinde olsun. afrostarvideos tablo, yaklaşık 2000 kayıtları vardır 300records hakkında afrostarprofiles. hatta sadece beş sorguyu sınırlayıcı sonra. Goto http://www.veepiz.com/index.php ve popüler sanatçıların altında bu nesil zaman kontrol. Bu sorguyu optimize yardımcı olun

//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);

0 Cevap