CREATE TABLE bayes_token (
  PRIMARY KEY (id, token),
  INDEX bayes_token_idx1 (token),
  INDEX bayes_token_idx2 (id, atime)
) TYPE=MyISAM;

PRIMARY for `id` and `token` should not have INDEX for `id` and `token`
added, too.

Why not?

IIRC the three indexes above makes perfect sense. Like this:

"WHERE id=xxx AND token=xxx" will use the primary index.

"WHERE token=xxx" will use the bayes_token_idx1 index.

"WHERE id=xxx AND atime=xxx" will use the bayes_token_idx2 index.

Again IIRC, the clause "WHERE token=xxx" should be faster with the existance of the 
"bayes_token_idx1" index than without it.

Or is it simply that the MySQL bayse store module never queries with "token" as 
the first column in a WHERE clause?

I might of course completely misremenber this, so rather than trust me I'd 
suggest reading about index optimization or something like that in the current 
MySQL documentation. :-)

Regards
/Jonas
--
Jonas Eckerman, FSDB & Fruktträdet
http://whatever.frukt.org/
http://www.fsdb.org/
http://www.frukt.org/

Reply via email to