MySQL的大量锁定查询

时间:2013-11-20 16:01:48

标签: php mysql sql

首先,当涉及到服务器和MySQL时,我是一个完全的菜鸟。那么,有了答案,如果可能的话,请你解释一下吗?我们不久前失去了我们的主要Web开发人员,我只知道一些HTML和PHP编码,所以我对这些东西感到茫然。

目前,我们的服务器一直在崩溃。我的意思是,每天10-12次我们的网站全都倒闭了。我已联系过我们的主持人,他们认为他们发现了这个问题,但他说这是我们的网络开发人员需要研究的问题。所以,基本上,他们不会帮助我们。

他们所说的是,“MySQL存在问题,因为数据库中有很多锁定查询正在查杀服务器。”然后他们列出了查询。以下是他们提供的清单:

+-----+---------------+-----------+----------------------+---------+------+--------------+-----------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
----------------------------------------------------------------------------------------------------+

| 296 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 297 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 302 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1983 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 304 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1979 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 308 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1984 | Sending data | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 311 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1984 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 313 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1979 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 317 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 319 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1979 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 322 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 327 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 329 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 332 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 334 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1984 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 336 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 342 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 343 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 344 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1983 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 348 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1983 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 350 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1979 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 356 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1978 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 360 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1979 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 361 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1983 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_posts.I |
| 365 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1945 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 366 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1884 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 368 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1909 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 373 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1824 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 374 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1813 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 376 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1641 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 392 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1436 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 394 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1411 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 396 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1411 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 399 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1383 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 403 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1335 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 406 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1336 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 411 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1281 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 415 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1062 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 416 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1038 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 418 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1038 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 419 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 1018 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 420 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 989 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 421 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 989 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 422 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 918 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 426 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 824 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 427 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 691 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 431 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 631 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 432 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 631 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 435 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 542 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 437 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 542 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 441 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 478 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 442 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 414 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 445 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 352 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT
wp_comment |
| 446 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 302 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 447 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 309 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT
wp_comment |
| 449 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 174 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 450 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 174 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 451 | wp_1265455606 | localhost | wordpress_1265455606 | Query | 73 | Locked | insert into cs365_change (id,table_id,trigger_time,trigger_day,expression,hashmd5)
SELECT

wp_comment |
| 453 | root | localhost | | Query | 1 | | show processlist 

这是我应该解决的问题吗?这是一个很大的问题,因为我们有一个目前总是关闭的网上商店。任何帮助,方向指示等都会非常感激!

1 个答案:

答案 0 :(得分:1)

我怀疑您使用的是MyISAM表。 MyISAM使用表级锁定,因此每当您执行插入操作时,整个表都会被锁定。切换到InnoDB将允许使用行级锁定,这可以防止插入时发生争用。

这可以通过为每个表执行ALTER TABLE t1 ENGINE=InnoDB;来完成。

请参阅MySQL docs