ParisNakitaKejser
ParisNakitaKejser

Reputation: 14949

SQL performance ( MySQL )

i have this tabel,

CREATE TABLE `forum_rank` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(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;

Upvotes: 1

Views: 91

Answers (2)

Florin Dumitrescu
Florin Dumitrescu

Reputation: 8292

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.

Upvotes: 4

duffymo
duffymo

Reputation: 308998

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.

Upvotes: 4

Related Questions