guyeuro
V2EX  ›  问与答

mysql 的 limit 优化

  •  
  •   guyeuro · Sep 11, 2017 · 2053 views
    This topic created in 3192 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   ·   2913 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:12 · PVG 23:12 · LAX 08:12 · JFK 11:12
    ♥ Do have faith in what you're doing.