[제나플러스] 100만건이 넘는 데이터의 카운트를 조정하려할때 > 팁앤테크

본문 바로가기

사이트 내 전체검색

뒤로가기 팁앤테크

[제나플러스] 100만건이 넘는 데이터의 카운트를 조정하려할때

본문

그누보드 게시판 관리자페이지에 보면,
해당게시판의 카운트를 조절하는 부분이 있습니다.
기존방식으로 하면 다소 느릴 수 있는 것을 최적화 해보았습니다.
 
파일 : /adm/board_form_update.php
라인 : 207 라인근처 ( // 글수 조정 ) 주석 아래입니다.
 
 변경전
 // 글수 조정
    if ($proc_count) {
        // 원글을 얻습니다.
        $sql = " select wr_id from $g4[write_prefix]$bo_table where wr_is_comment = 0 ";
        $result = sql_query($sql);
        for ($i=0; $row=sql_fetch_array($result); $i++) {
   // 코멘트수를 얻습니다.
            $sql2 = sql_query(" select count(*) as cnt from $g4[write_prefix]$bo_table where wr_parent = '$row[wr_id]' and wr_is_comment = 1 ");
            $row2 = sql_fetch_array($sql2);
            sql_query(" update $g4[write_prefix]$bo_table set wr_comment = '$row2[cnt]' where wr_id = '$row[wr_id]' ");
   echo ".";
   if ($i%50==0) { echo "<br/>";  flush(); }
        }
  mysql_free_result($result);
 }
 
 
 
변경후
 // 글수 조정
    if ($proc_count) {
        // 원글을 얻습니다.
        $sql = " select a.wr_id,count(b.wr_parent) as cnt from $g4[write_prefix]$bo_table a, $g4[write_prefix]$bo_table b where a.wr_id=b.wr_parent and a.wr_is_comment=0 group by a.wr_id desc ";
        $result = sql_query($sql);
        for ($i=0; $row=sql_fetch_array($result); $i++) {
   
        sql_query(" update $g4[write_prefix]$bo_table set wr_comment = '$row[cnt]' where wr_id = '$row[wr_id]' ");
   echo ".";
   if ($i%50==0) { echo "<br/>";  flush(); }
        }
  mysql_free_result($result);
 }
추천0

댓글목록 0

등록된 댓글이 없습니다.

전체 825건 11 페이지
게시물 검색
Copyright (c) 株式会社YHPLUS. All rights reserved.

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒171-0014 東京都豊島区池袋2-41-5 アーバン154 8F
050-5539-7787
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

PC 버전으로 보기