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

본문 바로가기
사이트 내 전체검색

팁앤테크

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

페이지 정보

profile_image
작성자 제로
댓글 0건 조회 82,727회 작성일 11-10-04 11:34

본문

그누보드 게시판 관리자페이지에 보면,
해당게시판의 카운트를 조절하는 부분이 있습니다.
기존방식으로 하면 다소 느릴 수 있는 것을 최적화 해보았습니다.
 
파일 : /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);
 }

댓글목록

등록된 댓글이 없습니다.

Total 829건 1 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 날짜
829 제로 8659 06-18
828 제로 11680 03-21
827 제로 10119 02-23
826 제로 35086 11-02
825 제로 37862 07-10
824 제로 58498 04-06
823 제로 35843 02-21
822 제로 45269 12-31
821 제로 35261 12-24
820 제로 35033 12-04
819 제로 38560 10-17
818 제로 36971 10-02
817 제로 73345 08-04
816 제로 34951 08-04
815 제로 53842 08-03
814 제로 53552 07-08
813 제로 89113 07-08
812 제로 108918 07-06
811 제로 36176 06-09
810 제로 43172 06-03
809 제로 41356 04-16
808 제로 42259 03-29
807 제로 35057 03-26
806 제로 45453 03-12
805 제로 37679 03-10

검색


사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒140-0011 東京都品川区東大井2-5-9-203
050-5470-4714
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

접속자집계

오늘
24,756
어제
37,399
최대
552,140
전체
16,168,410
Copyright (c) 株式会社YHPLUS. All rights reserved.