pg_stat_user_indexes不统计索引使用情况

postgresql数据库pg_stat_user_indexes不统计索引使用情况

首先检查代码是否满足使用索引条件。

select 前添加explain analyze

例如:explain analyze select * from test where id=1;

如提示:则是正常走了索引的,pg_stat_user_indexes会正常统计

仅参考(

index scan using test_pkey on test(cont=0.00..8.27 rows=1 width=408)(actual time=0.008..0.009 rows=1 loops=1)

index cond:(id=1)

total runtime:0.026 ms

如提示:则是未正常走索引

仅参考(

seq scan no test(cost=0.00..1.01 rows=1 width=408)(actual time=0.014..0.0015 rows1 loops=1)

filter:(id=1)

planning time:0.079 ms

execution time:0.029 ms

执行set enable_seqscan=off;可以解决此类问题

新增索引后之前走的索引不走了也可以执行explain analyze;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值