explain.depesz.com

PostgreSQL's explain analyze made readable

Result: qPZU

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 2,732.438 ↑ 1.3 76 1

Limit (cost=4,939.32..5,666.01 rows=100 width=390) (actual time=610.930..2,732.438 rows=76 loops=1)

2.          

Initplan (forLimit)

3. 0.014 0.153 ↑ 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.153..0.153 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.019..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. 89.780 217.922 ↑ 1.0 1 1

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

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

  • Filter: (customer_id IS NOT NULL)
  • Rows Removed by Filter: 24824
8. 0.352 2,732.396 ↑ 1,048.6 76 1

Nested Loop Left Join (cost=4.90..579,145.09 rows=79,695 width=390) (actual time=610.929..2,732.396 rows=76 loops=1)

9. 0.132 2,731.892 ↑ 1,048.6 76 1

Nested Loop Left Join (cost=4.46..531,539.31 rows=79,695 width=385) (actual time=610.771..2,731.892 rows=76 loops=1)

10. 0.356 2,731.532 ↑ 1,048.6 76 1

Nested Loop Left Join (cost=4.03..471,592.80 rows=79,695 width=381) (actual time=610.767..2,731.532 rows=76 loops=1)

11. 0.441 2,730.416 ↑ 1,048.6 76 1

Nested Loop Left Join (cost=3.60..411,646.28 rows=79,695 width=377) (actual time=610.745..2,730.416 rows=76 loops=1)

12. 0.133 1,494.139 ↑ 209.7 76 1

Nested Loop Left Join (cost=2.15..190,889.68 rows=15,939 width=277) (actual time=0.261..1,494.139 rows=76 loops=1)

13. 0.134 1,493.854 ↑ 209.7 76 1

Nested Loop Left Join (cost=1.72..178,900.38 rows=15,939 width=273) (actual time=0.258..1,493.854 rows=76 loops=1)

14. 0.192 1,493.492 ↑ 209.7 76 1

Nested Loop Left Join (cost=1.29..169,379.23 rows=15,939 width=269) (actual time=0.252..1,493.492 rows=76 loops=1)

15. 0.117 1,491.476 ↑ 209.7 76 1

Nested Loop Left Join (cost=0.85..159,858.07 rows=15,939 width=265) (actual time=0.215..1,491.476 rows=76 loops=1)

  • Join Filter: (unhandled_deals.deal_id = deal.id)
  • Rows Removed by Join Filter: 75
16. 36.425 1,491.283 ↑ 209.7 76 1

Nested Loop (cost=0.85..159,617.70 rows=15,939 width=261) (actual time=0.196..1,491.283 rows=76 loops=1)

17. 977.782 977.782 ↓ 7.4 119,269 1

Index Scan Backward using deal_pkey on deal (cost=0.43..99,796.70 rows=16,100 width=96) (actual time=0.089..977.782 rows=119,269 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: 963068
18. 477.076 477.076 ↓ 0.0 0 119,269

Index Scan using deal_state_pkey on deal_state (cost=0.43..3.72 rows=1 width=165) (actual time=0.004..0.004 rows=0 loops=119,269)

  • Index Cond: (deal_id = deal.id)
  • Filter: ((last_status_state <> 'DONE'::text) AND (last_status_state <> 'DISCARDED'::text))
  • Rows Removed by Filter: 1
19. 0.060 0.076 ↑ 1.0 1 76

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

20. 0.016 0.016 ↑ 1.0 1 1

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

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

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.024..0.024 rows=1 loops=76)

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

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=76)

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

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=76)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (action = 'BUY_SENT'::text))
24. 361.546 1,235.836 ↑ 5.0 1 76

Hash Right Join (cost=1.45..15.25 rows=5 width=104) (actual time=14.519..16.261 rows=1 loops=76)

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

Function Scan on list_customer_by_id (cost=0.25..10.25 rows=1,000 width=68) (actual time=8.039..11.642 rows=43,091 loops=75)

26. 0.152 1.140 ↑ 1.0 1 76

Hash (cost=1.18..1.18 rows=1 width=40) (actual time=0.015..0.015 rows=1 loops=76)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
27. 0.988 0.988 ↑ 1.0 1 76

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

  • Index Cond: (deal_id = deal.id)
28. 0.760 0.760 ↓ 0.0 0 76

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.010..0.010 rows=0 loops=76)

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

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=76)

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

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.002..0.002 rows=0 loops=76)

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