鍍金池/ 問答/Java  PHP  數(shù)據(jù)庫  網(wǎng)絡(luò)安全/ php在統(tǒng)計(jì)數(shù)據(jù)的時(shí)候如何優(yōu)化

php在統(tǒng)計(jì)數(shù)據(jù)的時(shí)候如何優(yōu)化

        $add_clues_where[0] = array("dealers_id" => $dealers_id,"time"=> $today);
        $add_clues_where[1] = array("dealers_id" => $dealers_id,"time"=> $week);
        $add_clues_where[2] = array("dealers_id" => $dealers_id,"time"=> $last_week);
        $add_clues_where[3] = array("dealers_id" => $dealers_id,"time"=> $moth);
        $add_clues_where[4] = array("dealers_id" => $dealers_id,"time"=> $last_moth);
        $add_clues_where[5] = array("dealers_id" => $dealers_id);
        foreach ($add_clues_where as $key => $value) {
            $add_clues[] = $DC -> CountClues($value);
        }

用的是thinkphp, CountClues是cure查詢;
現(xiàn)在我能想到,就這是上面這樣,依次傳入不同的搜索條件,然后循環(huán)查詢結(jié)果,取出結(jié)果,但是我的頁面還有很多這樣的查詢,打開頁面都2秒多了,如何優(yōu)化呢

回答
編輯回答
伴謊

如果實(shí)時(shí)性沒有要求的話可以用緩存做。或者使用異步查詢出來結(jié)果后放到緩存中

2018年5月5日 07:27
編輯回答
無標(biāo)題

建議把歷史數(shù)據(jù)按某一周期歸檔

2017年11月19日 03:19