0
나는이mysql을 선택 쿼리는 매우 느리고 filesort를 사용
explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE subject ALL NULL NULL NULL NULL 230026 Using where; Using filesort
를 사용할 때 느린 쿼리에서 하나의 큰 문제가 0.3054 초
이 쿼리
SELECT id, ar_name, en_name,product_id,havproduct, viewnum, uid,pin_to, sid, ssid,cid, close,date
FROM subject
where active = '1' and deleted = '0' and cid= '24'
order by id DESC
LIMIT 0,30
을 선택하고있다
및이 표 만들기
CREATE TABLE `subject` (
`id` int(11) NOT NULL,
`cid` int(11) NOT NULL,
`did` int(11) NOT NULL,
`sid` int(11) NOT NULL,
`ssid` int(11) NOT NULL,
`product_id` int(11) NOT NULL DEFAULT '0',
`havproduct` int(11) NOT NULL DEFAULT '0',
`uid` int(11) NOT NULL,
`ar_name` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`en_name` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`close` int(11) NOT NULL DEFAULT '0',
`active` int(11) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`viewnum` int(11) NOT NULL DEFAULT '1',
`pin_to` int(11) NOT NULL DEFAULT '0',
`deleted` int(11) NOT NULL,
`user_active` int(11) NOT NULL DEFAULT '1',
`dep_active` int(11) NOT NULL DEFAULT '1'
) ENGINE=MyISAM DEFAULT CHARSET=utf8
이고 테이블에 데이터에서 200000 이상의 레코드가 있습니다.