On Thu, 27 Sep 2007 08:22:31 +0300, Henrik Krohns wrote: > On Thu, Sep 27, 2007 at 05:11:09AM +0000, micah wrote: >> On Thu, 27 Sep 2007 07:48:02 +0300, Henrik Krohns wrote: >> >> > On Thu, Sep 27, 2007 at 03:27:51AM +0000, micah wrote: >> >> On Wed, 26 Sep 2007 17:54:05 -0700, John D. Hardin wrote: >> >> >> >> > On Wed, 26 Sep 2007, Micah Anderson wrote: >> >> > >> >> >> SELECT count(*) >> >> >> FROM bayes_token >> >> >> WHERE id = '4' >> >> >> AND ('1190846660' - atime) > '345600'; >> >> > >> >> > Who the hell wrote *that* query? Is MySQL smart enough to >> >> > rearrange that equation to give an indexable comparison? >> >> >> >> That comes from /usr/share/perl5/Mail/SpamAssassin/BayesStore/SQL.pl >> >> line 243. It seems to calculate the expire delta, but in a way that >> >> can't use an index. >> >> >> >> Maybe that query should be changed from: >> >> >> >> AND (? - atime) > ?" >> >> returns: 1039123 >> >> >> >> to: >> >> >> >> AND atime < ? + ?" >> >> returns: 1039231 >> >> > I think you mean: >> > >> > AND atime < ? - ? >> >> returns: 0 > > If you think about it, minus is the logical way. You must have some > strange atime values.
No, what I did was screw up the operator... what I meant to originally say was it should be changed to this: AND atime > ? + ? but I switched the operator around, and you corrected my math, by keeping the operator: AND atime < ? - ? which is functionally the same... although I think the first one is better because it keeps the operator the same as the original query. micah