내 WordPress 사이트에서 사용자가 게시물 목록에서 멀리 페이지를 이동하면 쿼리가 몇 초가 걸립니다. 나는 이것을 내리고 싶다. 다음은 실행중인 쿼리입니다.이전 게시물에 대한 WordPress SQL 쿼리 최적화 목록
SELECT SQL_CALC_FOUND_ROWS wp_posts.*
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = 'post'
AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
ORDER BY wp_posts.post_date DESC
LIMIT 846, 47
테이블에 약 160,000 개의 행이 있습니다. 다음은 스키마의 단순화 된 버전입니다 :
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp_posts ref type_status_date type_status_date 62 const 41519 Using where; Using filesort
적으로는, 내가이 filesort 제거 싶습니다
CREATE TABLE `wp_posts` (
`ID` bigint(20) unsigned NOT NULL auto_increment,
`post_date` datetime NOT NULL default '0000-00-00 00:00:00',
`post_status` varchar(20) NOT NULL default 'publish',
`post_type` varchar(20) NOT NULL default 'post',
PRIMARY KEY (`ID`),
KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8
이것은 EXPLAIN
쿼리의 결과입니다. 어떤 팁?
에 매겨진 디스플레이를 최적화에
더 많은 정보 ...? –
인덱스는 질문의 테이블 스키마에 있습니다. ID에는 기본 키가 있고 복합 색인에는 'post_type','post_status','post_date','ID'가 있습니다. –