Michael Alan Dorman wrote:
CREATE TABLE bayes_token ( PRIMARY KEY (id, token), INDEX bayes_token_idx1 (token), INDEX bayes_token_idx2 (id, atime) ) TYPE=MyISAM;
If the primary key was changed to (token, id), it should be able to be used in the second sort of query as well as the first, no?
Ah. Yes. I missed that. Yes, if the key was (token, id), there might be no need at all for the "bayes_token_idx1" index above. Sorry for my confusion. I'm no SQL or MySQL guru, so maybe I'm missing something though. I have no idea how one best optimizes a MySQL table for using "WHERE xxx IN (yyy)" for example, and the module does have WHERE id = ? AND token IN (...) ... in a UPDATE statement. Could that be the reason for the separate (token) index? I'm supposing that whoever wrote the MySQL bayes storage module had a reason for doing what they did and that I simply am not good enough at SQL to realize what the reason is. :-) Regards /Jonas -- Jonas Eckerman, FSDB & Fruktträdet http://whatever.frukt.org/ http://www.fsdb.org/ http://www.frukt.org/