explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YQEF

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 952.021 ↑ 1.0 100 1

Limit (cost=4,939.32..24,088.58 rows=100 width=386) (actual time=0.216..952.021 rows=100 loops=1)

2.          

Initplan (forLimit)

3. 0.000 0.088 ↑ 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.088..0.088 rows=1 loops=1)

4. 0.010 0.010 ↑ 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.007..0.010 rows=39 loops=1)

5. 0.078 0.078 ↑ 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.002..0.002 rows=1 loops=39)

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

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

7. 68.816 68.816 ↑ 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.008..68.816 rows=173,574 loops=1)

  • Filter: (customer_id IS NOT NULL)
  • Rows Removed by Filter: 24824
8. 0.271 951.983 ↑ 8.1 100 1

Nested Loop Left Join (cost=4.90..154,156.46 rows=805 width=386) (actual time=0.215..951.983 rows=100 loops=1)

9. 0.099 951.512 ↑ 8.1 100 1

Nested Loop Left Join (cost=4.46..150,679.04 rows=805 width=381) (actual time=0.122..951.512 rows=100 loops=1)

10. 0.166 951.113 ↑ 8.1 100 1

Nested Loop Left Join (cost=4.03..144,962.57 rows=805 width=377) (actual time=0.119..951.113 rows=100 loops=1)

11. 0.327 950.247 ↑ 8.1 100 1

Nested Loop Left Join (cost=3.60..139,246.11 rows=805 width=373) (actual time=0.116..950.247 rows=100 loops=1)

12. 0.146 7.520 ↑ 1.6 100 1

Nested Loop Left Join (cost=2.15..137,014.82 rows=161 width=273) (actual time=0.103..7.520 rows=100 loops=1)

13. 0.071 7.174 ↑ 1.6 100 1

Nested Loop Left Join (cost=1.72..135,871.52 rows=161 width=269) (actual time=0.100..7.174 rows=100 loops=1)

14. 0.143 6.803 ↑ 1.6 100 1

Nested Loop Left Join (cost=1.29..135,176.04 rows=161 width=265) (actual time=0.096..6.803 rows=100 loops=1)

15. 0.066 6.260 ↑ 1.6 100 1

Nested Loop Left Join (cost=0.85..134,480.55 rows=161 width=261) (actual time=0.087..6.260 rows=100 loops=1)

  • Join Filter: (unhandled_deals.deal_id = deal.id)
  • Rows Removed by Join Filter: 99
16. 0.000 6.094 ↑ 1.6 100 1

Nested Loop (cost=0.85..134,476.85 rows=161 width=257) (actual time=0.073..6.094 rows=100 loops=1)

17. 1.671 1.671 ↑ 7.3 1,489 1

Index Scan Backward using deal_state_pkey on deal_state (cost=0.43..86,089.32 rows=10,823 width=165) (actual time=0.019..1.671 rows=1,489 loops=1)

  • Filter: (last_status_state = ANY ('{DONE,REVIEW}'::text[]))
  • Rows Removed by Filter: 147
18. 4.467 4.467 ↓ 0.0 0 1,489

Index Scan using deal_pkey on deal (cost=0.43..4.47 rows=1 width=96) (actual time=0.003..0.003 rows=0 loops=1,489)

  • Index Cond: (id = deal_state.deal_id)
  • 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: 1
19. 0.089 0.100 ↑ 1.0 1 100

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

20. 0.011 0.011 ↑ 1.0 1 1

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

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

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

  • Index Cond: ((deal_id = deal.id) AND (action = 'OFFER_SENT'::text))
22. 0.300 0.300 ↑ 2.0 1 100

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

  • Index Cond: ((deal_id = deal.id) AND (action = 'PAID'::text))
23. 0.200 0.200 ↑ 1.0 1 100

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

  • Index Cond: ((deal_id = deal.id) AND (action = 'BUY_SENT'::text))
24. 247.670 942.400 ↓ 0.0 0 100

Hash Right Join (cost=1.45..15.25 rows=5 width=104) (actual time=8.755..9.424 rows=0 loops=100)

  • Hash Cond: (list_customer_by_id.id = deal_customer.customer_id)
25. 694.130 694.130 ↓ 43.1 43,091 41

Function Scan on list_customer_by_id (cost=0.25..10.25 rows=1,000 width=68) (actual time=12.496..16.930 rows=43,091 loops=41)

26. 0.100 0.600 ↓ 0.0 0 100

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

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
27. 0.500 0.500 ↓ 0.0 0 100

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

  • Index Cond: (deal_id = deal.id)
28. 0.700 0.700 ↑ 1.0 1 100

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

  • Index Cond: ((deal_id = deal.id) AND (action = 'BUY_RECEIVED'::text))
29. 0.300 0.300 ↑ 1.0 1 100

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

  • Index Cond: ((deal_id = deal.id) AND (action = 'SELL_SENT'::text))
30. 0.200 0.200 ↑ 2.0 1 100

Index Scan using deal_actions_deal_id_action_uindex on deal_actions action_sell_received_table (cost=0.43..8.21 rows=2 width=8) (actual time=0.002..0.002 rows=1 loops=100)

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