리스트에 자기가 댓글 단 글에 표시되게 하려면..? 속도 개선 방법부탁해요..

게시판 리스트를 볼때 자기가 댓글을 써놓은 글 제목에만 옆에 특별한 아이콘을 붙여서  사용자가 확인하기가 용이하게 만들고 싶습니다.
 
list.php에서
 
while ($row = sql_fetch_array($result))
{
    // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
    if ($sca || $stx)
        $row = sql_fetch(" select * from $write_table where wr_id = '$row[wr_parent]' ");
 
    $list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);
//여기 추가..자기댓글 표시
        $row2 = sql_fetch(" select count(*) as cnt from $write_table where wr_parent = {$list[$i][wr_id]} and mb_id = '$member[mb_id]' and wr_id != wr_parent ");
        if($row2[cnt]>0) $list[$i][my]= 1;
//여기까지..

    if (strstr($sfl, "subject"))
        $list[$i][subject] = search_font($stx, $list[$i][subject]);
    $list[$i][is_notice] = false;
    //$list[$i][num] = number_format($total_count - ($page - 1) * $board[bo_page_rows] - $k);
    $list[$i][num] = $total_count - ($page - 1) * $board[bo_page_rows] - $k;
    $i++;
    $k++;
}
 
위처럼 해봤는데 속도가 엄청 느려지더군요..
 
게시글이 3만 여건 정도 되서요..
 
이리해보고 저리해보고 하다 안되서 글 올립니다..
 
속도를 개선 시킬 수 있는 방법 없을까요??
 
제 머리로는 한계가..;;
 
도움 좀 부탁드립니다..
|

댓글 4개

"select count(*) as cnt from $write_table where wr_is_comment = '1' and mb_id = '$member[mb_id]'" 로 하시면 않되나요?

mb_id에 인덱스도 줘보시구용..
감사합니다 ^^ 인덱스가 힌트군요..
//여기 추가..자기댓글 표시
$row2 = sql_fetch(" select count(*) as cnt from $write_table where wr_parent = {$list[$i][wr_id]} and mb_id = '$member[mb_id]' and wr_id != wr_parent ");
if($row2[cnt]>0) $list[$i][my]= 1;
//여기까지..

where 조건이 index를 사용하지 않나 봅니다.


where wr_parent = {$list[$i][wr_id]}
and mb_id = '$member[mb_id]'
and wr_id != wr_parent ");

index 구성

PRIMARY | 1 | wr_id | A
wr_num_reply_parent | 1 | wr_num | A
wr_num_reply_parent | 2 | wr_reply | A
wr_num_reply_parent | 3 | wr_parent | A
wr_is_comment | 1 | wr_is_comment | A
wr_is_comment | 2 | wr_id | A |

개선 방법

mb_id가 들어 가게 index를 추가해야 합니다.

alter table add index mb_id ( mb_id, wr_parent, wr_id);
고맙습니다..^^ 하나 또 배우고 가네요~ 아직 적용 안해봤지만 우선 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다. 로그인

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
19년 전 조회 1,536
19년 전 조회 1,531
19년 전 조회 2,206
19년 전 조회 1,567
19년 전 조회 1,527
19년 전 조회 1,574
19년 전 조회 1,580
19년 전 조회 1,523
19년 전 조회 1,826
19년 전 조회 1,727
19년 전 조회 1,534
19년 전 조회 1,705
19년 전 조회 1,512
19년 전 조회 1,814
19년 전 조회 2,170
19년 전 조회 1,601
19년 전 조회 1,520
19년 전 조회 1,569
19년 전 조회 1,706
19년 전 조회 1,544
🐛 버그신고