开发者社区> 问答> 正文

700万数据的表,过滤条件在2万多数据做聚合,有索引,需要十几秒时间

700万数据的表,过滤条件在2万多数据做聚合,有索引,需要十几秒时间

Query Text: select sum(amount) from TABLE where A = '123456789' and B = true;

    Aggregate  (cost=100551.79..100551.80 rows=1 width=8) (actual time=11150.263..11150.264 rows=1 loops=1)
      ->  Index Scan using index_TABLE_on_A on TABLE  (cost=0.56..100477.26 rows=29809 width=8) (actual time=0.091..11131.577 rows=23198 loops=1)
            Index Cond: ((A)::text = '123456789'::text)
            Filter: B
            Rows Removed by Filter: 9934
            
            还有优化的地方吗
            

本问题来自云栖社区【PostgreSQL技术进阶社群】。https://yq.aliyun.com/articles/690084 点击链接欢迎加入社区大社群。

展开
收起
游客886 2019-06-18 16:30:34 2636 0
1 条回答
写回答
取消 提交回答
  • buffer, cluster

    2019-07-17 23:37:20
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
RowKey与索引设计:技巧与案例分析 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载