I had a 'news' table with almost 7.500 rows:
Structure:
CREATE TABLE `news` (
`newsId` int(10) unsigned NOT NULL auto_increment,
`chanId` tinyint(3) unsigned NOT NULL default '0',
`adminId` int(11) default NULL,
`newsTitle` varchar(255) NOT NULL default '',
`newsSubTitle` varchar(255) NOT NULL default '',
`newsHeadline` text NOT NULL,
`newsNews` text NOT NULL,
`newsBy` varchar(150) NOT NULL default '',
`newsPic` varchar(20) default NULL,
`newsPicCaption` text,
`newsKeywords` varchar(255) default NULL,
`newsSource` varchar(255) NOT NULL default '',
`newsAddedOn` int(10) unsigned NOT NULL default '0',
`newsAddedDate` date NOT NULL,
`newsViewed` int(10) unsigned NOT NULL default '0',
`newsType` char(2) default NULL,
PRIMARY KEY (`newsId`),
KEY `chanId` (`chanId`),
KEY `addedon` (`newsAddedOn`),
KEY `chanIdnewsId` (`chanId`,`newsId`)
) ENGINE=InnoDB AUTO_INCREMENT=7542 DEFAULT CHARSET=utf8;
I am doing a simple query like this:
SELECT * FROM news ORDER BY newsAddedOn DESC LIMIT 0,5
using EXPLAIN, I received this:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE news index NULL newsAddedOn 4 NULL 7428
how to make this simple innocent query not reading my whole table coz I only need 5 latest news.
thanks in advance.