explain.depesz.com

PostgreSQL's explain analyze made readable

Result: h1CL

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

Limit (cost=4,938.54..32,111.69 rows=100 width=386) (actual time=503.991..1,322.974 rows=100 loops=1)

2.          

Initplan (forLimit)

3. 0.039 0.219 ↑ 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.219..0.219 rows=1 loops=1)

4. 0.063 0.063 ↑ 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.058..0.063 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. 24.319 78.013 ↑ 1.0 1 1

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

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

  • Filter: (customer_id IS NOT NULL)
  • Rows Removed by Filter: 24824
8. 0.401 1,322.928 ↑ 5.5 100 1

Nested Loop Left Join (cost=4.12..150,815.10 rows=555 width=386) (actual time=503.989..1,322.928 rows=100 loops=1)

9. 0.165 1,322.227 ↑ 5.5 100 1

Nested Loop Left Join (cost=3.69..148,085.44 rows=555 width=381) (actual time=503.753..1,322.227 rows=100 loops=1)

10. 0.223 1,321.662 ↑ 5.5 100 1

Nested Loop Left Join (cost=3.26..143,686.30 rows=555 width=377) (actual time=503.739..1,321.662 rows=100 loops=1)

11. 0.416 1,321.239 ↑ 5.5 100 1

Nested Loop Left Join (cost=2.82..139,287.15 rows=555 width=373) (actual time=503.716..1,321.239 rows=100 loops=1)

12. 433.800 1,317.123 ↑ 5.5 100 1

Nested Loop Left Join (cost=2.39..134,888.00 rows=555 width=369) (actual time=501.262..1,317.123 rows=100 loops=1)

  • Join Filter: (deal_customer.customer_id = list_customer_by_id.id)
  • Rows Removed by Join Filter: 4309062
13. 0.201 10.323 ↑ 1.1 100 1

Nested Loop Left Join (cost=2.14..132,390.25 rows=111 width=305) (actual time=1.023..10.323 rows=100 loops=1)

14. 0.259 9.722 ↑ 1.1 100 1

Nested Loop Left Join (cost=1.71..131,844.32 rows=111 width=301) (actual time=1.013..9.722 rows=100 loops=1)

15. 0.223 4.163 ↑ 1.1 100 1

Nested Loop Left Join (cost=1.27..131,298.39 rows=111 width=297) (actual time=0.565..4.163 rows=100 loops=1)

  • Join Filter: (unhandled_deals.deal_id = deal.id)
  • Rows Removed by Join Filter: 99
16. 0.166 3.440 ↑ 1.1 100 1

Nested Loop Left Join (cost=1.27..131,295.44 rows=111 width=293) (actual time=0.061..3.440 rows=100 loops=1)

17. 0.277 2.774 ↑ 1.1 100 1

Nested Loop (cost=0.85..131,007.62 rows=111 width=257) (actual time=0.056..2.774 rows=100 loops=1)

18. 1.622 1.622 ↑ 44.6 125 1

Index Scan Backward using deal_pkey on deal (cost=0.43..98,443.77 rows=5,573 width=96) (actual time=0.046..1.622 rows=125 loops=1)

  • Filter: ((office_id = 8) OR ((type = ANY ('{AGENT_OFFICE,CUSTOMER,CORRECTION}'::text[])) AND ((sender_office_id = 8) OR (receiver_office_id = 8))))
  • Rows Removed by Filter: 1497
19. 0.875 0.875 ↑ 1.0 1 125

Index Scan using deal_state_pkey on deal_state (cost=0.43..5.84 rows=1 width=165) (actual time=0.007..0.007 rows=1 loops=125)

  • Index Cond: (deal_id = deal.id)
  • Filter: (last_status_state = ANY ('{INVOICED,DRAFT,REVIEW,DONE}'::text[]))
  • Rows Removed by Filter: 0
20. 0.500 0.500 ↓ 0.0 0 100

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

  • Index Cond: (deal_id = deal.id)
21. 0.000 0.500 ↑ 1.0 1 100

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

22. 0.501 0.501 ↑ 1.0 1 1

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

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

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

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

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

  • Index Cond: ((deal_id = deal.id) AND (action = 'PAID'::text))
25. 873.000 873.000 ↓ 43.1 43,091 100

Function Scan on list_customer_by_id (cost=0.25..10.25 rows=1,000 width=68) (actual time=4.835..8.730 rows=43,091 loops=100)

26. 3.700 3.700 ↑ 1.0 1 100

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

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

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

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

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

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

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

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