使用 JOIN 时 phpMyAdmin 性能不佳
Poor performance in phpMyAdmin when using JOIN
对于特定网站,我 运行 在 phpMyAdmin 中进行以下简单查询:
SELECT a.`Nom_ID`
FROM `aa_produse_asbis` a
LEFT JOIN `aa_sku` s ON a.`Nom_ID` = s.`sku`
WHERE s.`sku` IS NULL
其中 a.Nom_ID
有大约 5.000 条记录,s.sku
有大约 75.000 条记录。两列都设置为 UNIQUE 并且是 varchar(255)。查询需要 120 多秒,但如果我同时浏览网站,它会完美运行。此外,简单的 SELECT 查询工作正常......但不是 JOIN。他们以前响应非常快,但我不知道是什么原因导致性能不佳(没有更改列索引)。
还有一件事:当我尝试进入 MySQL 控制台 (mysql -u root - p
) 时,我得到:mysql: unknown variable 'asocket=/var/run/mysqld/mysqld.sock'
.
phpMyAdmin 性能不佳的原因是什么?
LE:EXPLAIN 语句如下所示:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a index NULL Nom_ID 767 NULL 4771 Using index
1 SIMPLE s index NULL sku 257 NULL 73728 Using where; Using index; Not exists
似乎字段有不同的排序规则。现在使用相同的排序规则后 运行 没问题。
对于特定网站,我 运行 在 phpMyAdmin 中进行以下简单查询:
SELECT a.`Nom_ID`
FROM `aa_produse_asbis` a
LEFT JOIN `aa_sku` s ON a.`Nom_ID` = s.`sku`
WHERE s.`sku` IS NULL
其中 a.Nom_ID
有大约 5.000 条记录,s.sku
有大约 75.000 条记录。两列都设置为 UNIQUE 并且是 varchar(255)。查询需要 120 多秒,但如果我同时浏览网站,它会完美运行。此外,简单的 SELECT 查询工作正常......但不是 JOIN。他们以前响应非常快,但我不知道是什么原因导致性能不佳(没有更改列索引)。
还有一件事:当我尝试进入 MySQL 控制台 (mysql -u root - p
) 时,我得到:mysql: unknown variable 'asocket=/var/run/mysqld/mysqld.sock'
.
phpMyAdmin 性能不佳的原因是什么?
LE:EXPLAIN 语句如下所示:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a index NULL Nom_ID 767 NULL 4771 Using index
1 SIMPLE s index NULL sku 257 NULL 73728 Using where; Using index; Not exists
似乎字段有不同的排序规则。现在使用相同的排序规则后 运行 没问题。