非常慢的innodb操作

时间:2017-05-19 16:07:34

标签: mysql innodb mariadb

我有用于将url与我们的数据库网址进行比较并仅保存新网址的php脚本。问题是这个脚本的每一步都需要很长时间(总共超过10分钟)。以下是步骤:

$query = sprintf("DELETE FROM %s ; ", $DB ['compare_result_table']);

$query = sprintf("LOAD DATA INFILE '%s' IGNORE INTO TABLE %s
        FIELDS TERMINATED BY ','
        ENCLOSED BY \"'\"
        LINES TERMINATED BY '\n'
        (domain, url_value)",
      $real_out_path, $DB["compare_result_table"]);

$query = sprintf(" INSERT INTO %s SELECT domain 
        FROM %s ;", $DB ['compare_url_table'], 'domain_data' );

$query = sprintf("DELETE a.*
              FROM %s a INNER JOIN %s b using (domain);",
         $DB["compare_result_table"], $DB ['compare_url_table']);

这里是表格描述:

DROP TABLE IF EXISTS cmp_url;
CREATE TABLE cmp_url
(
    domain varchar(255),
    index (domain)
);

DROP TABLE IF EXISTS cmp_result;
CREATE TABLE cmp_result
(
    domain varchar(255),
    url_value varchar(4096),
    index (domain)

);

每次我调用show PROCESSLIST时,我都会看到每一步(不包括文件中的数据加载)都需要很长时间。 domain_data表包含我们要比较的域,现在是600 000条记录。它越大,所有步骤就越慢。

这是我在my.cnf中更改的一些选项:

innodb_lock_wait_timeout = 360
innodb_autoinc_lock_mode=2
binlog_format=mixed
transaction-isolation = READ-COMMITTED

但它不会改变任何事情。我该如何解决这个问题?谢谢你的时间。

1 个答案:

答案 0 :(得分:0)

完全替换表:

Cannot complete the install because one or more required items could not be found.
  Software being installed: IBM Dojo Mobile Tools 7.1.0.00-20160726-1659 (com.ibm.imp.dojo.tools.licensed.feature.feature.group 7.1.0.00-20160726-1659)
  Missing requirement: Model Plug-in 8.0.0.v20160726_1542 (com.ibm.etools.webtools.model 8.0.0.v20160726_1542) requires 'bundle org.eclipse.gmf.runtime.emf.type.core [1.0.0,2.0.0)' but it could not be found
  Cannot satisfy dependency:
    From: Rich Page Editor - Dojo extensions 1.1.500.v20160726_1542 (com.ibm.etools.rpe.dojo 1.1.500.v20160726_1542)
    To: bundle com.ibm.etools.webtools.model [8.0.0,9.0.0)
  Cannot satisfy dependency:
    From: Dojo Web Tools 2.1.200.v20160726_1542 (com.ibm.etools.webtools.dojo.feature.feature.group 2.1.200.v20160726_1542)
    To: com.ibm.etools.rpe.dojo [1.1.500.v20160726_1542]
  Cannot satisfy dependency:
    From: IBM Dojo Mobile Tools 7.1.0.00-20160726-1659 (com.ibm.imp.dojo.tools.licensed.feature.feature.group 7.1.0.00-20160726-1659)
    To: com.ibm.etools.webtools.dojo.feature.feature.group 1.0.0

快速。零停机时间。