[英]perl with mysql, terribly slow, how to fix it
I have a very tiny perl script which extract one column from original table to form a new table, and generate the relation table by the way 我有一个很小的perl脚本,它从原始表中提取一列以形成一个新表,并通过这种方式生成关系表
$sqr->$conn->prepare("select id, authors from paper");
$sqr->execute();
while(@row = $sqr->fetchrow_array()) {
paper_id = $row[0];
@author_arr = someExtractFunc($row[1]);
for (@author_arr) {
author_id = insertAuthor($_);
insertAuthorPaper(author_id, paper_id); # this is the relation_table between author and paper
}
}
I have 80,000papers, about 240,000 authors, and this script runs terribly slow, can any one tell me why and give me some advice? 我有80,000篇论文,大约240,000位作者,而且此脚本运行非常慢,有人可以告诉我原因并给我一些建议吗?
paper
id authors title
author
id name
author_paper
id author_id paper_id
This can probably be solved entirely in MySQL by running query like 这可以完全通过在MySQL中运行查询来解决,例如
INSERT INTO
newTable(field1,field2,...)
SELECT
field1, field2
FROM
oldTable;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.