最近,我们在Production Aurora PG集群中遇到了性能问题。这是查询的EXPLAIN ANALYZE。
大部分时间都花在
Bitmap Index Scan on job_stage (cost=0.00..172.93 rows=9666 width=0) (actual time=238.410..238.410 rows=2019444 loops=1)上,在该位置上扫描了2019444。但是,令我困扰的是此表中只有70k行。 Autovacuum已打开,但是RDS最近因另一个问题而超载。我们怀疑自动真空正在运行。如果是这样,是否可以解释我们的观察结果,即扫描的行超过了表中的实际行?
Nested Loop (cost=229.16..265.28 rows=1 width=464) (actual time=239.815..239.815 rows=0 loops=1) -> Nested Loop (cost=228.62..252.71 rows=1 width=540) (actual time=239.814..239.814 rows=0 loops=1) Join Filter: (job.scanner_uuid = scanner_resource_pool.resource_uuid) Rows Removed by Join Filter: 1 -> Index Scan using scanner_resource_pool_scanner_index on scanner_resource_pool (cost=0.41..8.43 rows=1 width=115) (actual time=0.017..0.019 rows=1 loops=1) Index Cond: ((box_uuid = '5d8a7e0c-23ff-4853-bb6d-ffff6a38afa7'::text) AND (scanner_uuid = '9be9ac50-de05-4ddd-9545-ddddc484dce'::text)) -> Bitmap Heap Scan on job (cost=228.22..244.23 rows=4 width=464) (actual time=239.790..239.791 rows=1 loops=1) Recheck Cond: ((box_uuid = '5d8a7e0c-23ff-4853-bb6d-ffff6a38afa7'::text) AND (stage = 'active'::text)) Rows Removed by Index Recheck: 6 Heap Blocks: exact=791 -> BitmapAnd (cost=228.22..228.22 rows=4 width=0) (actual time=238.913..238.913 rows=0 loops=1) -> Bitmap Index Scan on job_box_status (cost=0.00..55.04 rows=1398 width=0) (actual time=0.183..0.183 rows=899 loops=1) Index Cond: (box_uuid = '5d8a7e0c-23ff-4853-bb6d-ffff6a38afa7'::text) -> Bitmap Index Scan on job_stage (cost=0.00..172.93 rows=9666 width=0) (actual time=238.410..238.410 rows=2019444 loops=1) Index Cond: (stage = 'active'::text) -> Index Only Scan using uc_box_uuid on scanner (cost=0.54..12.56 rows=1 width=87) (never executed) Index Cond: ((box_uuid = '5d8a7e0c-23ff-4853-bb6d-ffff6a38afa7'::text) AND (uuid = '9be9ac50-de05-4ddd-9545-ddddc484dce'::text)) Heap Fetches: 0 Planning time: 1.274 ms Execution time: 239.876 ms
答案 0 :(得分:0)
我通过与AWS确认找到了答案。如果自动清理落后,则EXPLAIN ANALYZE结果可能显示出这种差异。