V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
skyboy
V2EX  ›  问与答

mysql 和 postgresql 的性能测试

  •  
  •   skyboy · 2016-12-08 16:45:57 +08:00 · 1381 次点击
    这是一个创建于 2703 天前的主题,其中的信息可能已经有所发展或是发生改变。
    分别用 php 的几个框架,全部用原生 PDO 语句,连接了 mysql5.7 和 postgresql9.6 数据库,两种数据库中的表结构索引一样。

    一个表分别有 3000W 行记录,并用同样的语句查询:

    select * from typecho_comments where author=(select author from typecho_comments order by coid desc limit 1); 返回最后一条结果 echo 在页面上。

    然后用 ab 工具在本机对网站做测试 ab -c100 -n100 example.com/ 返回结果如下,这个结果说明了什么呢。

    slim+postgresql request per second: 45
    lumen+postgresql request per second: 41
    laravel+postgresql request per second: 38

    slim+myesql request per second: 356
    lumen+mysql request per second: 206
    laravel+mysql request per second: 137

    可以看到,postgresql 数据库的结果,几个框架相差不大。而 mysql 的结果,几个框架相差一倍以上。这说明了什么 ?各框架性能相差巨大,还是两种数据库性能相差巨大?
    1 条回复    2016-12-09 13:11:05 +08:00
    skyboy
        1
    skyboy  
    OP
       2016-12-09 13:11:05 +08:00
    若把语句上面的测试语句由 xx select limit 1;改为:select * from table1 order by id desc limit 3000. 则各框架每秒支持的请求数差别不大:

    frame my pg

    slim3: 57 26

    lumen: 57 25

    laravel: 56 28 ​

    这又是为什么?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2380 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 06:44 · PVG 14:44 · LAX 23:44 · JFK 02:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.