MySQL MyISAM " Table1 " 有70% 的 select、13% 的 update和0.67% 的 insert语句。
有一个“ count_column(int) ”用于使用主键增加计数。(更新语句)
更新“ count_column ”在“Waiting for table level lock”中进行表选择查询
那么在其他表中分离“ count_column ”会减少 “等待表级锁”吗?
我还需要在带有连接的选择语句中分隔列。
谢谢, 约格
MySQL MyISAM " Table1 " 有70% 的 select、13% 的 update和0.67% 的 insert语句。
有一个“ count_column(int) ”用于使用主键增加计数。(更新语句)
更新“ count_column ”在“Waiting for table level lock”中进行表选择查询
那么在其他表中分离“ count_column ”会减少 “等待表级锁”吗?
我还需要在带有连接的选择语句中分隔列。
谢谢, 约格
在另一个表中移动频繁更新的单元格将大大减少表上的锁数量并加快对其进行选择。将表转换为 InnoDB 也有帮助(如果您不使用全文索引,MySQL 5.5 InnoDB 仍然不支持它们),因为它使用行级锁而不是表级锁。如果你有很多疑问,看看这篇关于实现高效计数器的文章
AFAIK your locking problem is the COUNT with INSERT, not the UPDATE itself - but you must have a huge bunch of SELECTs. Your question is lacking quite some details...
COUNT is really optimized on MyISAM tables, if you encounter problems with that you maybe should consider a count estimate or memory tables holding this value:-\ But an exact row count is stored for MyISAM that is extremely quick to get by the storage engine, so you maybe even slowed down MySQL with your solution. "Slow" COUNT is valid for engines like InnoDB because of their transactional nature.
One other thing to consider is, that storing a count in a column in the table itself is an additional column for each row and quite bad.
And if you are using triggers to accomplish that you should be aware of http://dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html#qandaitem-B-5-1-12 :)