So, how does one gather statistics on indexes? With InnoDB it’s one thing, with MyISAM it’s another thing. This post however, will focus on MyISAM. There are various ways, each having their own drawbacks and positive sides.
What about ANALYZE TABLE
? It’s great — very fast in
InnoDB. But with MyISAM a lock occurs while scanning the table.
OPTIMIZE TABLE
? Still relatively quick with MyISAM,
unless the table in question is huge. InnoDB requires an
ALTER TABLE
— it might take forever, depending on
the server configuration, as OPTIMIZE TABLE
for
InnoDB maps to a ALTER TABLE tableName ENGINE=InnoDB
We all know how ANALYZE TABLE
, REPAIR
TABLE
, and OPTIMIZE TABLE
work with MyISAM.
However, there’s a less explored way, for MyISAM — the
myisam_stats_method
.
…
[Read more]