explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2pRi

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 2,047.667 ↑ 1.0 100 1

Limit (cost=4,939.32..5,664.53 rows=100 width=390) (actual time=639.619..2,047.667 rows=100 loops=1)

2.          

Initplan (forLimit)

3. 0.033 0.172 ↑ 1,478,142.0 1 1

Nested Loop Anti Join (cost=0.28..942,815.73 rows=1,478,142 width=0) (actual time=0.172..0.172 rows=1 loops=1)

4. 0.022 0.022 ↑ 75,802.1 39 1

Seq Scan on deal_row (cost=0.00..76,837.83 rows=2,956,283 width=32) (actual time=0.016..0.022 rows=39 loops=1)

5. 0.117 0.117 ↑ 1.0 1 39

Index Only Scan using product_article_code_pk on product_article (cost=0.28..0.29 rows=1 width=9) (actual time=0.003..0.003 rows=1 loops=39)

  • Index Cond: (code = deal_row.code)
  • Heap Fetches: 38
6. 34.513 120.786 ↑ 1.0 1 1

Aggregate (cost=4,933.50..4,933.51 rows=1 width=32) (actual time=120.785..120.786 rows=1 loops=1)

7. 86.273 86.273 ↑ 1.1 173,574 1

Seq Scan on deal_customer deal_customer_1 (cost=0.00..4,439.98 rows=197,406 width=4) (actual time=0.010..86.273 rows=173,574 loops=1)

  • Filter: (customer_id IS NOT NULL)
  • Rows Removed by Filter: 24824
8. 0.501 2,047.603 ↑ 801.0 100 1

Nested Loop Left Join (cost=4.90..580,862.47 rows=80,095 width=390) (actual time=639.619..2,047.603 rows=100 loops=1)

9. 0.259 2,046.802 ↑ 801.0 100 1

Nested Loop Left Join (cost=4.46..533,077.76 rows=80,095 width=385) (actual time=639.434..2,046.802 rows=100 loops=1)

10. 0.568 2,046.243 ↑ 801.0 100 1

Nested Loop Left Join (cost=4.03..472,950.37 rows=80,095 width=381) (actual time=639.427..2,046.243 rows=100 loops=1)

11. 0.707 2,044.275 ↑ 801.0 100 1

Nested Loop Left Join (cost=3.60..412,822.98 rows=80,095 width=377) (actual time=639.373..2,044.275 rows=100 loops=1)

12. 0.275 8.068 ↑ 160.2 100 1

Nested Loop Left Join (cost=2.15..190,958.38 rows=16,019 width=277) (actual time=0.102..8.068 rows=100 loops=1)

13. 0.280 7.593 ↑ 160.2 100 1

Nested Loop Left Join (cost=1.72..178,932.91 rows=16,019 width=273) (actual time=0.099..7.593 rows=100 loops=1)

14. 0.268 7.013 ↑ 160.2 100 1

Nested Loop Left Join (cost=1.29..169,375.96 rows=16,019 width=269) (actual time=0.096..7.013 rows=100 loops=1)

15. 0.220 6.045 ↑ 160.2 100 1

Nested Loop Left Join (cost=0.85..159,819.02 rows=16,019 width=265) (actual time=0.086..6.045 rows=100 loops=1)

  • Join Filter: (unhandled_deals.deal_id = deal.id)
  • Rows Removed by Join Filter: 99
16. 0.512 5.725 ↑ 160.2 100 1

Nested Loop (cost=0.85..159,577.45 rows=16,019 width=261) (actual time=0.070..5.725 rows=100 loops=1)

17. 3.461 3.461 ↑ 55.1 292 1

Index Scan Backward using deal_pkey on deal (cost=0.43..99,796.70 rows=16,100 width=96) (actual time=0.021..3.461 rows=292 loops=1)

  • 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: 2930
18. 1.752 1.752 ↓ 0.0 0 292

Index Scan using deal_state_pkey on deal_state (cost=0.43..3.71 rows=1 width=165) (actual time=0.006..0.006 rows=0 loops=292)

  • Index Cond: (deal_id = deal.id)
  • Filter: (last_status_state <> 'DONE'::text)
  • Rows Removed by Filter: 1
19. 0.087 0.100 ↑ 1.0 1 100

Materialize (cost=0.00..1.29 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=100)

20. 0.013 0.013 ↑ 1.0 1 1

Seq Scan on unhandled_deals (cost=0.00..1.29 rows=1 width=4) (actual time=0.012..0.013 rows=1 loops=1)

  • Filter: (office_id = 8)
  • Rows Removed by Filter: 22
21. 0.700 0.700 ↑ 2.0 1 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_offer_sent_table (cost=0.43..0.76 rows=2 width=8) (actual time=0.007..0.007 rows=1 loops=100)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'OFFER_SENT'::text))
22. 0.300 0.300 ↓ 0.0 0 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_paid_table (cost=0.43..0.76 rows=2 width=8) (actual time=0.003..0.003 rows=0 loops=100)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'PAID'::text))
23. 0.200 0.200 ↓ 0.0 0 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_buy_sent_table (cost=0.43..0.75 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=100)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'BUY_SENT'::text))
24. 913.817 2,035.500 ↑ 5.0 1 100

Hash Right Join (cost=1.45..15.25 rows=5 width=104) (actual time=18.441..20.355 rows=1 loops=100)

  • Hash Cond: (list_customer_by_id.id = deal_customer.customer_id)
25. 1,120.383 1,120.383 ↓ 43.1 43,089 99

Function Scan on list_customer_by_id (cost=0.25..10.25 rows=1,000 width=68) (actual time=6.281..11.317 rows=43,089 loops=99)

26. 0.300 1.300 ↑ 1.0 1 100

Hash (cost=1.18..1.18 rows=1 width=40) (actual time=0.013..0.013 rows=1 loops=100)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
27. 1.000 1.000 ↑ 1.0 1 100

Index Scan using deal_customer_deal_id_ndx on deal_customer (cost=0.42..1.18 rows=1 width=40) (actual time=0.010..0.010 rows=1 loops=100)

  • Index Cond: (deal_id = deal.id)
28. 1.400 1.400 ↓ 0.0 0 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_buy_received_table (cost=0.43..0.75 rows=1 width=8) (actual time=0.014..0.014 rows=0 loops=100)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'BUY_RECEIVED'::text))
29. 0.300 0.300 ↓ 0.0 0 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_sell_sent_table (cost=0.43..0.75 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=100)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'SELL_SENT'::text))
30. 0.300 0.300 ↓ 0.0 0 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_sell_received_table (cost=0.43..0.76 rows=2 width=8) (actual time=0.003..0.003 rows=0 loops=100)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'SELL_RECEIVED'::text))