我在 MySQL 中发现了一些奇怪的(对我来说)行为。我有一个简单的查询:
SELECT CONVERT( `text`.`old_text`
USING utf8 ) AS stext
FROM `text`
WHERE `text`.`old_id` IN
(
SELECT `revision`.`rev_text_id`
FROM `revision`
WHERE `revision`.`rev_id`
IN
(
SELECT `page_latest`
FROM `page`
WHERE `page_id` = 108
)
)
当我运行它时,phpmyadmin 显示执行时间为 77.0446 秒。
但后来我替换
WHERE `text`.`old_id` IN
经过
WHERE `text`.`old_id` =
它的执行时间下降到大约 0.001 秒。此查询的结果
SELECT `revision`.`rev_text_id`
FROM `revision`
WHERE `revision`.`rev_id`
IN
(
SELECT `page_latest`
FROM `page`
WHERE `page_id` = 108
)
是
+------------+
|rev_text_id |
+------------+
|6506 |
+------------+
有人可以解释一下这种行为吗?