zbl430

Postgresql count 性能提升, 请大佬支招

  •  
  •   zbl430 · Sep 26, 2017 · 3732 views
    This topic created in 3347 days ago, the information mentioned may be changed or developed.

    数据 3000w+,有两个 index

    select count(index) from table
    

    时间大概 10 分钟 google 等搜了很多,不是很清楚,这里向 v2 大佬请教, 如何提高 count 速度!

    4 replies  •  2017-09-27 10:30:39 +08:00
    jetbillwin
    jetbillwin
    Sep 26, 2017❤️1
    1
    你这个问题值几万块,找个靠谱的 DBA 咨询一下吧
    tomczhen
    tomczhen
    Sep 26, 2017❤️1
    2
    通常这样做的目的是为了分页,实际阿里的 pgsql adb 德哥有专门发过一篇博客吐槽这个

    http://blog.163.com/digoal@126/blog/static/1638770402016468349463

    实际上根据业务情况也有一些不用 count 的方法来解决这个问题

    https://stackoverflow.com/questions/109232/what-is-the-best-way-to-paginate-results-in-sql-server
    est
    est
    Sep 26, 2017❤️1
    3
    写入频繁不?

    写入频繁没法做。
    peihanw
    peihanw
    Sep 27, 2017❤️1
    4
    升级到 9.6.x 版,启用 parallel 查询(根据 CPU 线程数调整配置文件中的 max_worker_processes 和 max_parallel_workers_per_gather 配置项),能大幅提高 OLAP 性能,分区表性能提高尤其明显。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   947 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 21:14 · PVG 05:14 · LAX 13:14 · JFK 16:14
    ♥ Do have faith in what you're doing.