问题描述
Postgres 版本: 12
查询: 解释(分析为真、详细为真、成本为真、缓冲区为真、时间为真) SELECT MIN("id"),MAX("id") FROM "public"."hotel_slot_inventory" WHERE ( "updated_at" >= '2021-03-02 13:30:03' AND "updated_at"
查询计划:
Result (cost=512.17..512.18 rows=1 width=8) (actual time=65556.920..65556.926 rows=1 loops=1)
Output: $0,$1
Buffers: shared hit=370 read=454012 written=8
I/O Timings: read=62266.717 write=0.194
InitPlan 1 (returns $0)
-> Limit (cost=0.57..256.09 rows=1 width=4) (actual time=65251.998..65252.001 rows=1 loops=1)
Output: hotel_slot_inventory.id
Buffers: shared hit=1 read=453546 written=8
I/O Timings: read=61967.042 write=0.194
-> Index Only Scan using hotel_slot_inventory_id_updated_at_idx on public.hotel_slot_inventory (cost=0.57..3291347.07 rows=12881 width=4) (actual time=65251.996..65251.997 rows=1 loops=1)
Output: hotel_slot_inventory.id
Index Cond: ((hotel_slot_inventory.id IS NOT NULL) AND (hotel_slot_inventory.updated_at >= '2021-03-02 13:30:03'::timestamp without time zone) AND (hotel_slot_inventory.updated_at < '2021-03-03 06:15:19.127884'::timestamp without time zone))
Heap Fetches: 1
Buffers: shared hit=1 read=453546 written=8
I/O Timings: read=61967.042 write=0.194
InitPlan 2 (returns $1)
-> Limit (cost=0.57..256.09 rows=1 width=4) (actual time=304.902..304.903 rows=1 loops=1)
Output: hotel_slot_inventory_1.id
Buffers: shared hit=369 read=466
I/O Timings: read=299.674
-> Index Only Scan Backward using hotel_slot_inventory_id_updated_at_idx on public.hotel_slot_inventory hotel_slot_inventory_1 (cost=0.57..3291347.07 rows=12881 width=4) (actual time=304.899..304.899 rows=1 loops=1)
Output: hotel_slot_inventory_1.id
Index Cond: ((hotel_slot_inventory_1.id IS NOT NULL) AND (hotel_slot_inventory_1.updated_at >= '2021-03-02 13:30:03'::timestamp without time zone) AND (hotel_slot_inventory_1.updated_at < '2021-03-03 06:15:19.127884'::timestamp without time zone))
Heap Fetches: 3892
Buffers: shared hit=369 read=466
I/O Timings: read=299.674
Planning Time: 0.229 ms
Execution Time: 65556.982 ms
(28 rows)
在 InitPlan1 中,为了获取 12881,它必须读取 453546 个缓冲区..这意味着有许多缓冲区不包含数据。真空也没有帮助。请在这里帮忙。我该如何解决这个问题?
编辑索引膨胀详细信息:
真实大小:3751411712 = 3.49 GB
额外大小:470237184 = 448 MB
额外比率:12.53
填充因子:90
膨胀大小:107053056 = 102 MB
膨胀比率:2.85
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)