explain.depesz.com

PostgreSQL's explain analyze made readable

Result: W0nV

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 1,741.032 ↑ 1.0 1 1

Finalize Aggregate (cost=18,361.24..18,361.25 rows=1 width=8) (actual time=1,741.032..1,741.032 rows=1 loops=1)

2. 11.157 1,741.029 ↓ 1.5 3 1

Gather (cost=18,361.02..18,361.23 rows=2 width=8) (actual time=1,741.016..1,741.029 rows=3 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
3. 26.031 1,729.872 ↑ 1.0 1 3

Partial Aggregate (cost=17,361.02..17,361.03 rows=1 width=8) (actual time=1,729.872..1,729.872 rows=1 loops=3)

4. 987.294 1,703.841 ↓ 56,182.5 112,365 3

Nested Loop (cost=344.09..17,361.02 rows=2 width=4) (actual time=103.827..1,703.841 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. 411.879 716.527 ↓ 397.5 39,752 3

Nested Loop (cost=343.66..16,586.13 rows=100 width=48) (actual time=103.698..716.527 rows=39,752 loops=3)

6. 194.435 304.639 ↓ 397.5 39,752 3

Parallel Bitmap Heap Scan on deal (cost=343.23..15,759.96 rows=100 width=44) (actual time=103.608..304.639 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=5177
7. 0.004 110.204 ↓ 0.0 0 1

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

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

Bitmap Index Scan on deal_type_receiver_office_id_index (cost=0.00..141.02 rows=5,412 width=0) (actual time=97.193..97.193 rows=1,015,558 loops=1)

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

  • Index Cond: (receiver_office_id = 8)
10. 9.742 9.742 ↓ 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=9.742..9.742 rows=108,742 loops=1)

  • Index Cond: (sender_office_id = 8)
11. 0.009 0.009 ↑ 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.009..0.009 rows=1 loops=119,257)

  • Index Cond: (deal_id = deal.id)
  • Heap Fetches: 42731
12. 0.020 0.020 ↑ 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.014..0.020 rows=4 loops=119,257)

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