Search code examples
mysqlinnodb

how to prevent "note : Table does not support optimize, doing recreate + analyze instead"


my problem is that i run mysqlcheck for InnoDB tables in a Cronjob and if i get everytime an e-mail with thousands of these messages i will easily overlook possible error messages.

--silent does not help either.

my best try till now is to | grep -v "note :" but i fear that i could be stripping out more important "notes"...

But even so mysqlcheck is listing every table in the DB which is already a pretty long list, still hiding possible error messages.

i haven't been able to find any relevant information about exit codes of mysqlcheck, for instance, to just send an e-mail if there is really something wrong.

so the question is: "How to run mysqlcheck and just get RELEVANT output"?


Solution

  • The simple answer is: Don't use mysqlcheck on InnoDB. And use only InnoDB.

    The error message comes from OPTIMIZE TABLE, which is all but useless for InnoDB. (It had some use for MyISAM.) InnoDB is good at keeping its tables in decent shape. That is, 99.9% of the time OPTIMIZE is a waste of time.

    Addenda

    Sure, InnoDB gets fragmented. Any BTree gets fragmented. (This includes MyISAM indexes, which are BTree-organized.) BTrees, even under heavy modification, tend to go from 0% fragmented to an average of 31% "free" space, then stay there. Sure, you could defragment to get that back, but further activity would promptly lose it. It's not worth the effort and downtime.

    That 31% does not translate into anything more than a negligible slowdown. Yes, it is a chunk of disk space, but optimize needs 100% to do its task because it copies the table over. So, you clearly have enough disk space.