开发者

SQL performance ( MySQL )

i have this tabel,

CREATE TABLE `forum_rank` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` in开发者_运维技巧t(11) NOT NULL DEFAULT '0',
  `rank` int(11) NOT NULL DEFAULT '0',
  `forum_id` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

now i ask about what perfome best, its * or alle felt like this 2 eg.

select * form forum_rank;

or

select id, user_id, rank, forum_id from forum_rank;


You should explicitly specify the columns. Otherwise the database engine will first have to find out what the table's columns are (resolve the * operator) and after perform the actual query.


I don't think performance will be a problem here. There's a better reason to prefer the second idiom: your code is less likely to break if you add additional columns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜