问题:给定一系列可空的开始日期和结束日期,优化以下查询的最佳方法是什么(下面是样例模式)SELECT * FROM daterangesSIMPLE, s, ALL, date_start_idx,date_end_idx, , , , 6340, Using where; Using temporary; Using filesort
示例MySQL
这是我的MYSQL表演示,它有超过700万行;| Field | Typewhere id>"43984a7e-edcf-11ea-92c7-509a4cb89342" order by date desc limit 30;
为了更快地执行上述查询,我在(id,date)上创建了一个索引然后我又在(日期)上做了另一个索引。花了不到1秒的时间。为什么复合索引