explain.depesz.com

PostgreSQL's explain analyze made readable

Result: FmCX

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 1,255.325 ↑ 1.0 1 1

Finalize Aggregate (cost=18,345.24..18,345.25 rows=1 width=8) (actual time=1,255.325..1,255.325 rows=1 loops=1)

2. 12.498 1,255.320 ↓ 1.5 3 1

Gather (cost=18,345.02..18,345.23 rows=2 width=8) (actual time=1,255.188..1,255.320 rows=3 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
3. 18.712 1,242.822 ↑ 1.0 1 3

Partial Aggregate (cost=17,345.02..17,345.03 rows=1 width=8) (actual time=1,242.821..1,242.822 rows=1 loops=3)

4. 682.944 1,224.110 ↓ 56,182.5 112,365 3

Nested Loop (cost=328.09..17,345.02 rows=2 width=4) (actual time=111.216..1,224.110 rows=112,365 loops=3)

  • Join Filter: ((deal.id = deal_row.deal_id) AND ((deal.type = 'CUSTOMER'::text) OR ((deal_row.quantity > '0'::numeric) AND (deal.receiver_office_id = 8)) OR ((deal_row.quantity <= '0'::numeric) AND (deal.sender_office_id = 8))))
  • Rows Removed by Join Filter: 44502
5. 278.612 541.152 ↓ 397.5 39,752 3

Nested Loop (cost=327.66..16,570.13 rows=100 width=48) (actual time=111.123..541.152 rows=39,752 loops=3)

6. 141.966 262.534 ↓ 397.5 39,752 3

Parallel Bitmap Heap Scan on deal (cost=327.23..15,743.96 rows=100 width=44) (actual time=111.031..262.534 rows=39,752 loops=3)

  • Recheck Cond: ((type = 'CUSTOMER'::text) OR (receiver_office_id = 8) OR (sender_office_id = 8))
  • Filter: ((office_id = 8) OR ((type <> 'AGENT'::text) AND (sender_office_id = 8)) OR ((type <> 'AGENT'::text) AND (receiver_office_id = 8)))
  • Rows Removed by Filter: 311175
  • Heap Blocks: exact=5112
7. 0.002 120.568 ↓ 0.0 0 1

BitmapOr (cost=327.23..327.23 rows=16,235 width=0) (actual time=120.568..120.568 rows=0 loops=1)

8. 111.374 111.374 ↓ 187.6 1,015,558 1

Bitmap Index Scan on deal_type_index (cost=0.00..125.02 rows=5,412 width=0) (actual time=111.374..111.374 rows=1,015,558 loops=1)

  • Index Cond: (type = 'CUSTOMER'::text)
9. 3.245 3.245 ↓ 8.7 46,868 1

Bitmap Index Scan on deal_receiver_office_id_ndx (cost=0.00..101.02 rows=5,412 width=0) (actual time=3.245..3.245 rows=46,868 loops=1)

  • Index Cond: (receiver_office_id = 8)
10. 5.947 5.947 ↓ 20.1 108,742 1

Bitmap Index Scan on deal_sender_office_id_ndx (cost=0.00..101.02 rows=5,412 width=0) (actual time=5.947..5.947 rows=108,742 loops=1)

  • Index Cond: (sender_office_id = 8)
11. 0.006 0.006 ↑ 1.0 1 119,257

Index Only Scan using deal_state_pkey on deal_state (cost=0.43..8.26 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=119,257)

  • Index Cond: (deal_id = deal.id)
  • Heap Fetches: 42629
12. 0.014 0.014 ↑ 37.0 4 119,257

Index Scan using deal_row_deal_id_product_article_type_quantity_index on deal_row (cost=0.43..4.05 rows=148 width=72) (actual time=0.010..0.014 rows=4 loops=119,257)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (product_article_type = ANY ('{PRODUCT,CURRENCY}'::text[])))