explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Qna8

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 1,219.002 ↑ 1.0 1 1

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

2. 7.050 1,218.998 ↓ 1.5 3 1

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

  • Workers Planned: 2
  • Workers Launched: 2
3. 18.588 1,211.948 ↑ 1.0 1 3

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

4. 678.150 1,193.360 ↓ 56,182.5 112,365 3

Nested Loop (cost=328.09..17,345.02 rows=2 width=4) (actual time=86.837..1,193.360 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. 276.006 515.196 ↓ 397.5 39,752 3

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

6. 149.570 239.184 ↓ 397.5 39,752 3

Parallel Bitmap Heap Scan on deal (cost=327.23..15,743.96 rows=100 width=44) (actual time=86.553..239.184 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=5161
7. 0.003 89.614 ↓ 0.0 0 1

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

8. 77.522 77.522 ↓ 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=77.522..77.522 rows=1,015,558 loops=1)

  • Index Cond: (type = 'CUSTOMER'::text)
9. 3.653 3.653 ↓ 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.653..3.653 rows=46,868 loops=1)

  • Index Cond: (receiver_office_id = 8)
10. 8.436 8.436 ↓ 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=8.436..8.436 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: 42530
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[])))