채택완료

24시간 글수 어떤게 더 효율적인가요 ?

//24시간 이내의 글 수 알아내기
function new_count($table_id){
 // 오늘을 불러옵니다.
 $intime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24));
 
 // 여기는 오늘과 글쓴 날짜를 비교합니다.
 $tmp_write_table .= "g4_write_$table_id"; 
 $sql2 = " select wr_datetime from $tmp_write_table where wr_datetime >= '$intime' and wr_is_comment = '0'";
 
 // 새로운 글이 몇개 있는지 확인합니다. 
 $result2 = sql_query($sql2); 
 $total_count = mysql_num_rows($result2);
 
 if ($total_count > 0) {
  $str_cnt .= $total_count;
  return $str_cnt;
 }
 else {
  $str_cnt .= "";
  return $str_cnt;
 }
}
----------------------------------------------------------------------------------------
 
//24시간 이내의 글 수 알아내기
function new_count($table_id){
 // 오늘을 불러옵니다.
 $intime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24));
 
 // 여기는 오늘과 글쓴 날짜를 비교합니다.
 $tmp_write_table .= "g4_write_$table_id"; 
 $sqlcomm = "SELECT count(*) AS cnt FROM $tmp_write_table WHERE wr_is_comment = '0' and wr_datetime >='$intime'";
    $row = sql_fetch($sqlcomm);
    $total_count = $row[cnt];
 
 if ($total_count > 0) {
  $str_cnt .= $total_count;
  return $str_cnt;
 }
 else {
  $str_cnt .= "";
  return $str_cnt;
 }
}
 
 
어떤게 더 효율적인가요?
|

답변 4개 / 댓글 1개

채택된 답변
+20 포인트
select wr_datetime ~~ 보다 SELECT count(*) ~~ 가 빠르다는 거...

많은 도움이 되었습니다. 감사합니다.

답변 감사합니다........
답변이 안달려서...

보통 2번째 방법을 많이 선호 하는것 같습니다.

답변에 대한 댓글 1개

본인 선호를 보통이란 말로 포장하지 마세요. 뿌잉뿌잉 ㅎㅎ

답변을 작성하려면 로그인이 필요합니다.