도와주세요!! 개발자님들!
안녕하세요. 오랜만에 접속하네요.
질문이 있을때 마다 SIR를 찾게되네요. 전문가분들이 너무 많으셔서요.
메인 검색
select substr(hv_datetime, 12, 2) as Times from hit_visit group by Times
하위 검색
select count(*) as Count from hit_visit where (1) and hv_set = 'Visit' and hv_datetime like '% ".$Row[0]['Times'].":%'
select count(distinct(hv_ip)) as Count from hit_visit where (1) and hv_set = 'Visit' and hv_datetime like '% ".$Row[0]['Times'].":%'
select count(*) as Count from hit_visit where (1) and hv_set = 'Purchase' and hv_datetime like '% ".$Row[0]['Times'].":%'
select count(*) as Count from hit_visit where (1) and hv_set = 'Put' and hv_datetime like '% ".$Row[0]['Times'].":%'
select count(*) as Count from hit_visit where (1) and hv_set = 'Attention' and hv_datetime like '% ".$Row[0]['Times'].":%'
이런 방식으로 불러오고 있습니다.
그런데 이용자가 많아지다보니 속도부분에서 너무 오래 걸리게 되더라구요..
혹시 한번에 처리 할 수 있는 방법은 없을까요?
간단한 예제 부탁드립니다.
그리고 감사합니다.^^
댓글 6개
(select count(*) as Count from hit_visit where (1) and hv_set = 'Visit' and hv_datetime like '% ".$Row[0]['Times'].":%' ) as hit_visit1
(select count(distinct(hv_ip)) as Count from hit_visit where (1) and hv_set = 'Visit' and hv_datetime like '% ".$Row[0]['Times'].":%' ) as hit_visit2
(select count(*) as Count from hit_visit where (1) and hv_set = 'Purchase' and hv_datetime like '% ".$Row[0]['Times'].":%' ) as hit_visit3
(select count(*) as Count from hit_visit where (1) and hv_set = 'Put' and hv_datetime like '% ".$Row[0]['Times'].":%' ) as hit_visit1
(select count(*) as Count from hit_visit where (1) and hv_set = 'Attention' and hv_datetime like '% ".$Row[0]['Times'].":%' ) as hit_visit4
이런식으로 해서
hit_visit1 ~ hit_visit4 까지 한번 에 가지오 올수 있습니다.
그리고 데이터 양이 많아서 속도가 느리면요..조건걸럼에다가 index를 걸어주시면 속도가 훨씬 빨라집니다.
그런데 ㅠㅠ 실행이 안되네요.. ㅠㅠ찡
$Select = "
select
(select count(*) as Count from hit_visit where (1) and hv_set = 'Visit' and hv_datetime like '% 05:%' ) as hit_visit1
(select count(distinct(hv_ip)) as Count from hit_visit where (1) and hv_set = 'Visit' and hv_datetime like '% 05:%' ) as hit_visit2
(select count(*) as Count from hit_visit where (1) and hv_set = 'Purchase' and hv_datetime like '% 05:%' ) as hit_visit3
(select count(*) as Count from hit_visit where (1) and hv_set = 'Put' and hv_datetime like '% 05:%' ) as hit_visit1
(select count(*) as Count from hit_visit where (1) and hv_set = 'Attention' and hv_datetime like '% 05:%' ) as hit_visit4
";
$Query = sql_query($Select);
while($Row = sql_fetch_array($Query)){
print_r($Row);
echo "<br/>";
}
윗 분님의 설명대로
index를 걸어도 도움은 됩니다만
약효는 금방 떨어질듯 합니다.
참고로 count(*) 보다 특정 컬럼 한개 예를들어 select count(no) 와 같이 처리하시는게 속도에 도움이됩니다.
저도 다시 잘 기억하겟습니다. 감사합니다.
게시판 목록
토크
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3600 |
nature1235
|
10개월 전 | 430 | |
| 3599 |
swallow
|
2년 전 | 1340 | |
| 3598 |
swallow
|
2년 전 | 1185 | |
| 3597 |
swallow
|
2년 전 | 791 | |
| 3596 | 2년 전 | 1408 | ||
| 3595 | 2년 전 | 687 | ||
| 3594 | 2년 전 | 1405 | ||
| 3593 |
|
3년 전 | 1232 | |
| 3592 |
|
3년 전 | 1565 | |
| 3591 |
|
3년 전 | 1478 | |
| 3590 |
|
3년 전 | 1420 | |
| 3589 |
|
3년 전 | 1234 | |
| 3588 |
|
3년 전 | 1217 | |
| 3587 |
|
4년 전 | 1134 | |
| 3586 |
|
4년 전 | 1368 | |
| 3585 |
|
4년 전 | 1288 | |
| 3584 |
|
4년 전 | 1034 | |
| 3583 |
Arm코리아
|
4년 전 | 1128 | |
| 3582 |
|
4년 전 | 1238 | |
| 3581 |
|
4년 전 | 2192 | |
| 3580 |
|
4년 전 | 1263 | |
| 3579 |
|
4년 전 | 1295 | |
| 3578 |
|
4년 전 | 1530 | |
| 3577 | 4년 전 | 1665 | ||
| 3576 |
|
4년 전 | 1657 | |
| 3575 |
|
4년 전 | 1668 | |
| 3574 |
|
4년 전 | 2086 | |
| 3573 |
|
4년 전 | 1544 | |
| 3572 |
|
4년 전 | 1530 | |
| 3571 |
|
4년 전 | 1611 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기