开发者

SQL performance ( MySQL )

开发者 https://www.devze.com 2023-01-25 21:22 出处:网络
i have this tabel, CREATE TABLE `forum_rank` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` in开发者_运维技巧t(11) NOT NULL DEFAULT \'0\',

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

精彩评论

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