explain.depesz.com

PostgreSQL's explain analyze made readable

Result: xNFc

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 439.673 ↑ 1.0 20 1

Limit (cost=4,937.15..5,049.95 rows=20 width=366) (actual time=267.120..439.673 rows=20 loops=1)

2.          

Initplan (forLimit)

3. 0.025 0.170 ↑ 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.170..0.170 rows=1 loops=1)

4. 0.028 0.028 ↑ 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.023..0.028 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.597 67.458 ↑ 1.0 1 1

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

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

  • Filter: (customer_id IS NOT NULL)
  • Rows Removed by Filter: 24824
8. 0.271 439.663 ↑ 3,984.8 20 1

Nested Loop Left Join (cost=2.73..449,467.68 rows=79,697 width=366) (actual time=267.119..439.663 rows=20 loops=1)

9. 0.046 2.052 ↑ 797.0 20 1

Nested Loop Left Join (cost=1.29..228,711.09 rows=15,939 width=265) (actual time=0.141..2.052 rows=20 loops=1)

10. 0.027 1.866 ↑ 797.0 20 1

Nested Loop Left Join (cost=0.85..159,858.07 rows=15,939 width=261) (actual time=0.132..1.866 rows=20 loops=1)

  • Join Filter: (unhandled_deals.deal_id = deal.id)
  • Rows Removed by Join Filter: 19
11. 0.136 1.799 ↑ 797.0 20 1

Nested Loop (cost=0.85..159,617.70 rows=15,939 width=257) (actual time=0.119..1.799 rows=20 loops=1)

12. 1.159 1.159 ↑ 127.8 126 1

Index Scan Backward using deal_pkey on deal (cost=0.43..99,796.70 rows=16,100 width=96) (actual time=0.021..1.159 rows=126 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: 1498
13. 0.504 0.504 ↓ 0.0 0 126

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

  • Index Cond: (deal_id = deal.id)
  • Filter: ((last_status_state <> 'DONE'::text) AND (last_status_state <> 'DISCARDED'::text))
  • Rows Removed by Filter: 1
14. 0.032 0.040 ↑ 1.0 1 20

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

15. 0.008 0.008 ↑ 1.0 1 1

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

  • Filter: (office_id = 8)
  • Rows Removed by Filter: 22
16. 0.140 0.140 ↑ 2.0 1 20

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.007..0.007 rows=1 loops=20)

  • Index Cond: ((deal_id = deal.id) AND (action = 'OFFER_SENT'::text))
17. 109.900 437.340 ↑ 5.0 1 20

Hash Right Join (cost=1.45..15.25 rows=5 width=104) (actual time=19.700..21.867 rows=1 loops=20)

  • Hash Cond: (list_customer_by_id.id = deal_customer.customer_id)
18. 327.260 327.260 ↓ 43.1 43,091 20

Function Scan on list_customer_by_id (cost=0.25..10.25 rows=1,000 width=68) (actual time=12.404..16.363 rows=43,091 loops=20)

19. 0.060 0.180 ↑ 1.0 1 20

Hash (cost=1.18..1.18 rows=1 width=40) (actual time=0.009..0.009 rows=1 loops=20)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
20. 0.120 0.120 ↑ 1.0 1 20

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

  • Index Cond: (deal_id = deal.id)