V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
RLinux
V2EX  ›  问与答

请教一个关于 mysqlr 如何走索引的问题,以及请教一下哪里可以查阅到比较系统的关于这方法的知识

  •  
  •   RLinux · Aug 9, 2021 · 1301 views
    This topic created in 1733 days ago, the information mentioned may be changed or developed.
    在一张四千万左右的消费表中,有两个索引( time1 )、( key_id,time1 )[之前就这样的,不是我弄的]。

    现在查询语句为 select * from key_id = * and time1 >= * and time1 <= *

    explain 得到的是 type=index,possible_keys=(time1)(key_id,time1)

    在网上搜到的资料看起来云里雾里的,不太懂为什么先走( time1 )~~

    PS:实际上不止这两个索引,但与此相关只有这两个。现在这个查询需要耗时两百多秒
    RLinux
        1
    RLinux  
    OP
       Aug 10, 2021
    0.0
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5820 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 76ms · UTC 02:39 · PVG 10:39 · LAX 19:39 · JFK 22:39
    ♥ Do have faith in what you're doing.