내가 5 백만 행 데이터베이스 테이블을 가지고, 나는 실행하고 있습니다 :이 날짜 범위 쿼리가 너무 느린 이유는 무엇입니까?
id (int pk auto inc)
actor (varchar)
action (enum)
target (varchar)
is_successful (tinyint)
datetime_created (datetime)
인덱스 :
select
*
from
tbl
where
datetime_created
between
'2014-10-01 00:00:00' and
'2014-10-31 23:59:59'
그것은 428k 결과
TBL에 열을 반환 54 초 걸렸습니다 :
datetime_created (datetime_created, action, target, is_successful)
개선 방법에 대한 의견이 있으십니까?
편집 :
은 EXPLAIN 결과 :
select_type: simple
type: range
possible keys
datetime_created
key: datetime_created
key_len: 8
ref: null
rows: 359569
extra: using index condition
접두사는 쿼리 전에 수행하고 무엇을하고 있는지 확인 – Khanna111
설명 : select_type : 단순형, 유형 : 범위, 가능한 키 : datetime_created, key : datetime_created, key_len : 8, ref : null, rows : 359569, extra : 인덱스 사용 조건 – john
설명은 인덱스를 사용하고 있지만 성능은 여전히 여전히 좋지 않음을 나타냅니다. – john