guyeuro
V2EX  ›  问与答

mysql 的 limit 优化

  •  
  •   guyeuro · Sep 11, 2017 · 2050 views
    This topic created in 3189 days ago, the information mentioned may be changed or developed.

    下面两个语句

    select phone from user  where id >(select id from user limit 3000000,1) order by id limit 0,10;
    
    select phone from user  order by id limit 3000001,10;
    

    测试多次,第一个总是比第二个好, 索引都是主键 id 为何会有区别?

    1 replies    2017-09-11 23:48:02 +08:00
    guyeuro
        1
    guyeuro  
    OP
       Sep 11, 2017
    顶顶顶!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3022 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:42 · PVG 16:42 · LAX 01:42 · JFK 04:42
    ♥ Do have faith in what you're doing.