场景:表A和表B关联 A.id = B.a_id 查询,并用表A的字段create_time排序(查询条件附带between create_time)
造成结果:explain结果如下,(查询结果耗时长)
原因:尚不明确.
解决方案:给B的a_id字段加上索引(create index index_a_id on B(a_id)),就解决了一部分问题.查询速度提升上来了.
explain的结果变成:
解决了一部分问题.至于using filesort,暂时先不优化了.已经够用了.
场景:表A和表B关联 A.id = B.a_id 查询,并用表A的字段create_time排序(查询条件附带between create_time)
造成结果:explain结果如下,(查询结果耗时长)
原因:尚不明确.
解决方案:给B的a_id字段加上索引(create index index_a_id on B(a_id)),就解决了一部分问题.查询速度提升上来了.
explain的结果变成:
解决了一部分问题.至于using filesort,暂时先不优化了.已经够用了.