I've seen a quirk in Mysql behavior over the years when dealing with max().
In a query such as this:

        select max(somecol) from sometbl where id=# and otherthing=#
        (index is on id, but not on otherthing)

We see the query run just fine (0.x seconds to run) almost all of the time.
But about 30 times a day it will take 4-20 seconds to run. It is not a
common query, and it is only slow occasionally. But it accounts for 100% of
slow queries logged.

If I change the query to this, it never shows up in the slow query log:

        select somecol from sometbl where id=# and otherthing=# order 
        by 1 desc limit 1

This behavior has acted like this for at least 5 years, in all versions that
I have had experience with, up to and including 4.0.18.

Someone else here had changed the query to use max() and that caused the
slow query log to have data, which despite half a billion queries a day,
should never happen. The above workaround still works, so it is no big deal.

I am a little surprised that this still happens though, and am curious if
anyone else has seen this as well, or is it just me?

-steve--





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to