开发者

Mysql table with 20Mil rows, and statistics getting out of date

开发者 https://www.devze.com 2023-01-25 00:00 出处:网络
I have a relatively simple myisam table in MySql which currently has about 20M rows. I insert about 200k rows a night.

I have a relatively simple myisam table in MySql which currently has about 20M rows.

I insert about 200k rows a night.

There are 3 indexes, one with 5 parts for a lookup, and 1 on the date technical key, and one on another technical key with very low cardinality. The server version is 5.0.45

What I'm finding is that a query which shou开发者_高级运维ld be using the date key (relatively high cardinality), is actually using the low cardinality key, and therefore going very slowly. If I analyze the table, then it works as expected. But I don't understand why I should have to analyze the table so frequently?? At the moment it seems I need to do it weekly - Is that normal?

(There are no updates/deletes in this table)

Rgds, Dan


You can use Mysql INDEX HINTS if it is not selecting the right index. For more information check here.

0

精彩评论

暂无评论...
验证码 换一张
取 消