Questions tagged «covering-index»

2
尽管缺少列但仍使用覆盖指数
我有以下查询,使用MariaDB 10 / InnoDB: SELECT id, sender_id, receiver_id, thread_id, date_created, content FROM user_message WHERE thread_id = 12345 AND placeholder = FALSE ORDER BY date_created DESC LIMIT 20 该查询根据给定的条件获取消息,并按创建日期排序。 我的覆盖范围超过(thread_id, date_created)。 当运行EXPLAIN时,使用正确的索引,尽管查询使用的是语句中间不在索引中的列,但我得到的输出为“在哪里使用”。我可以将任何值用于“占位符= x”,并且结果相同。 如果我将排序更改为使用另一列,则EXPLAIN正确指示“在哪里使用。使用文件排序”。 我正在抓头。有人可以阐明这一点吗?我希望看到的是,由于覆盖列无法完全使用,因此需要额外的文件排序。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.