日期:2014-05-16 浏览次数:20918 次
Create Table: CREATE TABLE `sina_weibo_status` ( `sid` bigint(20) NOT NULL DEFAULT '0', `text` varchar(255) DEFAULT NULL, `source` varchar(255) DEFAULT NULL, `truncated` int(1) DEFAULT NULL , `thumbnail_pic` varchar(255) DEFAULT NULL, `bmiddle_pic` varchar(255) DEFAULT NULL, `original_pic` varchar(255) DEFAULT NULL, `uid` bigint(20) DEFAULT NULL COMMENT, `retweeted_status` bigint(20) DEFAULT '0', `in_reply_to_status_id` bigint(20) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `aid` int(10) NOT NULL COMMENT, `category` int(10) NOT NULL, `status` tinyint(4) NOT NULL DEFAULT '0', `retweeted_num` int(11) NOT NULL DEFAULT '0', `rank` double NOT NULL DEFAULT '0', `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_date` datetime DEFAULT NULL, PRIMARY KEY (`sid`), KEY `sina_weibo_status_category_fk1` (`category`), KEY `sina_weibo_status_rank_index` (`rank`), KEY `sina_weibo_status_updated_date_index` (`updated_date`), KEY `sina_weibo_status_uid` (`uid`), KEY `sina_weibo_status_retweeted_status` (`retweeted_status`), CONSTRAINT `sina_weibo_status_ibfk_1` FOREIGN KEY (`category`) REFERENCES `category` (`id`) ON DELETE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8
mysql> explain SELECT * FROM `sina_weibo_status` `t` WHERE ((category='11') AND (status='0')) AND (retweeted_status='0') ORDER BY rank desc LIMIT 20 \G; *************************** 1. row *************************** id: 1 select_type: SIMPLE table: t type: index_merge possible_keys: sina_weibo_status_category_fk1,sina_weibo_status_retweeted_status key: sina_weibo_status_category_fk1,sina_weibo_status_retweeted_status key_len: 4,9 ref: NULL rows: 275502 Extra: Using intersect(sina_weibo_status_category_fk1,sina_weibo_status_retweeted_status); Using where; Using filesort