mysql explain filter
时间: 2023-09-10 15:11:01 浏览: 124
MySQL `EXPLAIN` is a command that is used to obtain information about how a SELECT query is executed by the MySQL optimizer. The `EXPLAIN` command provides the execution plan for a given SELECT query, which includes a detailed description of the access method, join type, and order of table access.
The `FILTER` option in MySQL `EXPLAIN` is used to show the conditions that are used to filter the rows in the result set. It is an optional clause that can be added to the `EXPLAIN` command to provide additional information about the query execution plan.
For example, consider the following query:
```
EXPLAIN SELECT * FROM employees WHERE salary > 50000 AND department = 'Sales';
```
The `EXPLAIN` command will provide the execution plan for the above query, and the `FILTER` option will show the conditions used to filter the rows in the result set. The output might look like this:
```
+----+-------------+-----------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Filter |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | employees | ref | salary | salary | 4 | NULL | 2 | salary > 50000 AND department = 'Sales' |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------------+
```
In the above output, the `Filter` column shows the conditions used to filter the rows in the result set, which is `salary > 50000 AND department = 'Sales'`. This means that the MySQL engine will use the `salary` index to filter the rows with a salary greater than 50000, and then further filter the rows with department 'Sales'.
阅读全文