sql 语句
select newsid,title,picurl,visit,visit1,comment,setlike,setlike1,collect,ctime,share,bigpic,source,leaflet from news where isvideo=0 and status=2 and ctime < '1496807186' and ctime > '1496764800' order by newsid desc limit 9;
表的schema
`newsid` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(128) NOT NULL COMMENT '标题',
`content` mediumtext NOT NULL COMMENT '内容',
`author` varchar(30) DEFAULT NULL COMMENT '作者',
`picurl` varchar(1024) DEFAULT NULL COMMENT '图片URL',
`ctime` int(11) DEFAULT NULL COMMENT '创建时间',
`source` varchar(30) NOT NULL COMMENT '来源',
`type` int(10) DEFAULT '1' COMMENT '类型 124小时 2视频 3娱乐...',
`status` int(10) DEFAULT '1' COMMENT '状态 0草稿 1已发布 2已审核 3删除',
`top` int(10) DEFAULT '0' COMMENT '属性 0正常,1置顶,',
`suggest` int(10) DEFAULT '0' COMMENT '属性 1推荐',
`visit` int(10) DEFAULT '0' COMMENT '访问次数',
`comment` int(10) DEFAULT '0' COMMENT '属性 评论数量',
`setlike` int(10) DEFAULT '0' COMMENT '属性 点赞数量',
`attention` int(10) DEFAULT '0' COMMENT '属性 关注数量',
`summary` varchar(1024) DEFAULT NULL COMMENT '摘要',
`visit1` int(10) DEFAULT '0' COMMENT '访问次数',
`setlike1` int(10) DEFAULT '0' COMMENT '属性 点赞数量',
`attention1` int(10) DEFAULT '0' COMMENT '属性 关注数量',
`oriurl` varchar(256) DEFAULT NULL COMMENT '爬取站点URL',
`optsrc` int(10) DEFAULT '0' COMMENT '属性 数据来源',
`writer` varchar(40) DEFAULT NULL COMMENT '发表人',
`headpic` varchar(255) DEFAULT NULL COMMENT '发表人头像',
`releasetime` int(12) DEFAULT '0' COMMENT '发布时间',
`share` int(6) DEFAULT '0' COMMENT '分享次数',
`collect` int(11) DEFAULT '0' COMMENT '收藏',
`bigpic` int(11) NOT NULL DEFAULT '0' COMMENT '大图标志0正常,1大图',
`leaflet` int(11) NOT NULL DEFAULT '0' COMMENT '广告标志0新闻,1广告',
`thefirst` int(11) NOT NULL DEFAULT '0' COMMENT '首条标志0正常,1首条',
`homefirst` int(11) NOT NULL DEFAULT '0' COMMENT '首页置顶标志0正常,1首条',
`isvideo` int(11) NOT NULL DEFAULT '0' COMMENT '是否视频0否,1是',
PRIMARY KEY (`newsid`),
KEY `index_news_status` (`status`),
KEY `index_news_type` (`type`),
KEY `index_news_homefirst` (`homefirst`),
KEY `index_news_ctime` (`ctime`),
KEY `index_news_top` (`top`),
KEY `index_news_title` (`title`),
KEY `index_news_suggest` (`suggest`),
KEY `index_news_isvideo` (`isvideo`)
) ENGINE=MyISAM AUTO_INCREMENT=451981 DEFAULT CHARSET=utf8 |
explan
explain select newsid,title,picurl,visit,visit1,comment,setlike,setlike1,collect,ctime,share,bigpic,source,leaflet from news where isvideo=0 and status=2 and ctime < '1496807186' and ctime > '1496764800' order by newsid desc limit 9;
结果
+----+-------------+-------+-------+-------------------------------------------------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+-------------------------------------------------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | news | index | index_news_status,index_news_ctime,index_news_isvideo | PRIMARY | 4 | NULL | 940 | Using where |
+----+-------------+-------+-------+-------------------------------------------------------+---------+---------+------+------+-------------+