Yes, the sorting in the query will use the index idx_age_deptId_name as it covers all the columns used in the WHERE clause and the ORDER BY clause. Specifically, the index will first filter the records based on age and deptId, and then sort the filtered records based on name in ascending order and deptId in descending order. The SQL_NO_CACHE hint disables caching of the query results.

create index idx_age_deptId_name on empage deptId name;explain SELECT SQL_NO_CACHE FROM emp WHERE age=35 and deptId =1 and name=abc order by name asc deptId desc; 排序会走索引吗

原文地址: https://www.cveoy.top/t/topic/czOK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录