g

코멘트 작성시 시간에 따라 + 표시가 생기는 것을 적용했는데...

예전에 작성했었는데,
답변에 대해 별 성과가 없어서 다시 이렇게 올립니다.


//코멘트 + 표시 타임
$intime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24)); //하루
$intime2 = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24 *2)); //이틀

$co_wr_parent = $list[$i][wr_id];
$co_wr_comment =substr($list[$i][comment_cnt],1,1);

$sqlcomm = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime'";
$row = sql_fetch($sqlcomm);

$sqlcomm2 = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime2'";
$row2 = sql_fetch($sqlcomm2);

if ($row[cnt])
echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:Tahoma;font-size:10px;color:#747474;'>{$list[$i][comment_cnt]}</span></a> <span style='font-family:Tahoma;font-size:9px;color:#FF0000;'>+</span>";
else if ($row2[cnt])
echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:Tahoma;font-size:10px;color:#747474;'>{$list[$i][comment_cnt]}</span></a> <span style='font-family:Tahoma;font-size:9px;color:#2080D0;'>+</span>";
else
echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:Tahoma;font-size:10px;color:#747474;'>{$list[$i][comment_cnt]}</span></a>";


...


코멘트를 작성하면,
List에 + 표시가 생기는데..
하루동안은 빨간색, 이틀까지는 파란색.. 그 이후로는 없어지는 소스입니다.

잘 됩니다. ^^


그런데 ... !!
DB부하가 엄청 일어나서, 서버측의 권고로 차단했는데..
이 기능을 꼭 사용해야 하는터라..

소스를 간략하게 줄이거나 부하를 해결할 수 있는 방법이 없을까요?
아니면 아예 새로이 바꿔주셔도 감사합니다.


도움 부탁드립니다~!!
|

댓글 3개

$sqlcomm = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime'";

위의 쿼리쪽부분에 index를 타게 하세요. 음..일단 그부보드의 게시판쪽 인덱스필드는 wr_id이고 그이외의 보조키가 wr_num,wr_reply,wr_parent,wr_is_comment 등이 있습니다.

시간은 키값에 해당하지 않는다는거죠..음..그렇다면
어차피 시간에 맞춰서 뽑아오는거니까..

$sqlcomm = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime' order by wr_num desc";

이렇게 한번 해보시죠..그나마 빨라질듯

추신: 테이블내에 선언되 키필드를 통해 검색해는게 대용량의 경우 속도면에서 우월하답니다.
조언에 감사드립니다 ^-^
일단 적용해봤어요. 상황 지켜보고 다시 또 질문드리겠습니다 ^^
정말 감사감사감사합니다~!
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

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

+
제목 글쓴이 날짜 조회
18년 전 조회 1,395
18년 전 조회 1,561
18년 전 조회 1,765
18년 전 조회 3,190
18년 전 조회 2,060
18년 전 조회 1,625
18년 전 조회 1,761
18년 전 조회 1,859
18년 전 조회 1,906
18년 전 조회 1,613
18년 전 조회 1,435
18년 전 조회 1,650
18년 전 조회 1,613
18년 전 조회 1,546
18년 전 조회 1,544
18년 전 조회 1,535
18년 전 조회 1,627
18년 전 조회 1,548
18년 전 조회 1,673
18년 전 조회 1,615