我有一个大型数据库(大约50GB)。它在我无法控制的服务器上,但我知道他们每晚都在使用mysqldump进行备份。可以在大型数据库上导致我的长查询挂起mysqldump?
我有一个查询需要几个小时才能完成。我将它设置为运行,但它实际上并未完成。我注意到,在备份时间之后,所有表都有一个锁请求(SHOW OPEN TABLES WHERE in_use> 0;列出所有表)。
从我的查询中的表有IN_USE = 2,其他所有表有IN_USE = 1
所以......这里发生了什么? a)我的查询正常运行,阻止转储发生。我应该等待? b)转储导致服务器挂起(可能缺少内存/磁盘空间?) c)别的东西?
编辑:使用MyISAM表
有一个服务器管理员谁也不是很能干的,但如果我问他具体的事情他做他们。我应该让他检查什么?
编辑:添加查询
SELECT citing.article_id as citing, citing.year, r.id_when_cited, cited_issue.country
FROM isi_lac_authored_articles as citing # 1M records
JOIN isi_citation_references r ON (citing.article_id = r.article_id) # 400M records
JOIN isi_articles cited ON (cited.id_when_cited = r.id_when_cited) # 25M records
JOIN isi_issues cited_issue ON (cited.issue_id = cited_issue.issue_id) # 1M records
这就是EXPLAIN不得不说:
+----+-------------+-------------+------+--------------------------------------------------------------------------+---------------------------------------+---------+-------------------------------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+--------------------------------------------------------------------------+---------------------------------------+---------+-------------------------------+---------+-------------+
| 1 | SIMPLE | cited_issue | ALL | NULL | NULL | NULL | NULL | 1156856 | |
| 1 | SIMPLE | cited | ref | isi_articles_id_when_cited,isi_articles_issue_id | isi_articles_issue_id | 49 | func | 19 | Using where |
| 1 | SIMPLE | r | ref | isi_citation_references_article_id,isi_citation_references_id_when_cited | isi_citation_references_id_when_cited | 17 | mimir_dev.cited.id_when_cited | 4 | Using where |
| 1 | SIMPLE | citing | ref | isi_lac_authored_articles_article_id | isi_lac_authored_articles_article_id | 16 | mimir_dev.r.article_id | 1 | |
+----+-------------+-------------+------+--------------------------------------------------------------------------+---------------------------------------+---------+-------------------------------+---------+-------------+
其实我不明白为什么它需要寻找在isi_issues表中的所有记录。难道它不应该通过issue_id上的isi_articles(引用)来匹配吗?这两个字段都被编入索引。
这里很难说,但听起来这是更多的服务器问题,备份可能会导致资源减少。尽管对于那些需要很长时间才能完成的查询,我会检查一个像www.infobright.org这样的分析数据库。 – 2012-03-14 18:06:03
我可以要求服务器管理员检查什么?我不认为他会安装分析数据库... – pocketfullofcheese 2012-03-14 18:18:44
我首先会找出他们使用MyIsam,InnoDB的存储引擎是什么样的......第二个发现备份通常完成而不试图运行您当时的查询,为您的查询获取基准但不运行 – 2012-03-14 19:26:17