리스트의 토탈 갯수를 구하려면 아래와 같이 쓰고 있습니다.
// 릿스트 구하기
function lists($page=1, $rowNo=20, $pagelistno=20)
{
$this->page_rows = $rowNo;
$this->page_list_size = $pagelistno;
$start_limit = (($page-1) * $rowNo);
// $this->db->where('bw_notice', 'qna');
$this->db->select('o.*, a.*');
$this->db->where( "o.CertFlag", "Y" ) ;
$this->db->from($this->table_name.' as o');
$this->db->join('ibtpoint as a', 'a.Idx = o.point_Idx', 'left');
$this->db->limit( $rowNo, $start_limit);
$this->kcSearch();
$query = $this->db->get();
echo $this->db->last_query();
return $query->result_array();
}
// Total 갯수 구하기
function total_cnt(){
//$this->db->select(" * ");
$this->db->select(" count(*) as total_cnt");
$this->db->from($this->table_name.' as o');
$this->db->join('ibtpoint as a', 'a.Idx = o.point_Idx', 'left');
$this->db->where( "o.CertFlag","Y" ) ;
$this->kcSearch();
$query = $this->db->get();
//return $query->num_rows();
return $query->row()->total_cnt;
}
//검색 조건
function kcSearch(){
@extract($_POST);
if(@$stx){
if ($sfl=="mID") { $this->db->like('o.mID', $stx); }
if ($sfl=="mName") { $this->db->like('o.mName', $stx); }
if ($sfl=="Email") { $this->db->like('o.Email', $stx); }
if ($sfl=="mTel") { $this->db->like('o.mTel', $stx); }
if ($sfl=="mMobile") { $this->db->like('o.mMobile', $stx); }
if ($sfl=="mRegdate") { $this->db->like('o.mRegdate', $stx); }
}
}
멤버테이블의 모델 부분인데요. 여기서 마크한 select * 를 한것과 count(*) 한것의 속도 차이와 리소스 잡아먹는 양은
체감적으로 많이 차이 날까요?
여러분들은 어떻게 하세요?
리스트를 구하기 위해 별도의 함수를 만들고
그들의 총 갯수를 구하는 쿼리문을 별도로 만들지 않고 num_rows 형태로 한 쿼리에서 뽑아 내나요?
웅파님 매번 빠른 응답 감사 합니다.
복받으세요.^^
해당 페이지 메모리 사용량과 쿼리의 실행시간이 나옵니다.
소스 주석처리해서 비교해보시면 되겠네요.
차이가 있을 겁니다.