explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5kXt

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 14.047 ↓ 2.0 2 1

Limit (cost=338.75..338.76 rows=1 width=53) (actual time=14.045..14.047 rows=2 loops=1)

2. 0.157 14.043 ↓ 2.0 2 1

Sort (cost=338.75..338.76 rows=1 width=53) (actual time=14.042..14.043 rows=2 loops=1)

  • Sort Key: user_coupons.id
  • Sort Method: quicksort Memory: 25kB
3. 0.025 13.886 ↓ 2.0 2 1

Nested Loop Left Join (cost=238.98..338.74 rows=1 width=53) (actual time=13.855..13.886 rows=2 loops=1)

  • Join Filter: (user_promotion_daily_usages.promotion_id = user_coupons.promotion_id)
  • Rows Removed by Join Filter: 2
  • Filter: ((user_promotion_daily_usages.id IS NULL) OR (promotions.per_user_daily_active_times > user_promotion_daily_usages.active_times))
  • Rows Removed by Filter: 1
4. 1.084 13.750 ↓ 3.0 3 1

Hash Right Join (cost=238.98..305.45 rows=1 width=57) (actual time=13.744..13.750 rows=3 loops=1)

  • Hash Cond: (eatery_promotions.promotion_id = promotions.id)
5. 1.423 1.423 ↓ 1.0 2,580 1

Seq Scan on eatery_promotions (cost=0.00..56.79 rows=2,579 width=4) (actual time=0.046..1.423 rows=2,580 loops=1)

6. 0.013 11.243 ↓ 3.0 3 1

Hash (cost=238.97..238.97 rows=1 width=61) (actual time=11.243..11.243 rows=3 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
7. 0.274 11.230 ↓ 3.0 3 1

Hash Right Join (cost=228.98..238.97 rows=1 width=61) (actual time=11.213..11.230 rows=3 loops=1)

  • Hash Cond: (user_promotion_usages.promotion_id = user_coupons.promotion_id)
  • Filter: ((promotions.per_user_active_times > user_promotion_usages.active_times) OR (user_promotion_usages.id IS NULL))
8. 0.430 0.430 ↓ 1.0 434 1

Seq Scan on user_promotion_usages (cost=0.00..8.33 rows=433 width=12) (actual time=0.029..0.430 rows=434 loops=1)

9. 0.014 10.526 ↓ 1.5 3 1

Hash (cost=228.95..228.95 rows=2 width=65) (actual time=10.526..10.526 rows=3 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
10. 0.107 10.512 ↓ 1.5 3 1

Nested Loop (cost=10.28..228.95 rows=2 width=65) (actual time=10.390..10.512 rows=3 loops=1)

  • Join Filter: (user_coupons.promotion_id = promotions.id)
11. 4.360 9.759 ↓ 3.2 38 1

Hash Join (cost=10.00..223.86 rows=12 width=61) (actual time=9.479..9.759 rows=38 loops=1)

  • Hash Cond: (promotion_usages.promotion_id = user_coupons.promotion_id)
12. 5.023 5.023 ↑ 1.0 7,483 1

Seq Scan on promotion_usages (cost=0.00..138.37 rows=7,537 width=8) (actual time=0.030..5.023 rows=7,483 loops=1)

13. 0.081 0.376 ↓ 3.2 39 1

Hash (cost=9.85..9.85 rows=12 width=53) (actual time=0.376..0.376 rows=39 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 4kB
14. 0.194 0.295 ↓ 3.2 39 1

Bitmap Heap Scan on user_coupons (cost=4.45..9.85 rows=12 width=53) (actual time=0.169..0.295 rows=39 loops=1)

  • Recheck Cond: (user_id = 9,552,678)
  • Filter: ((limit_phone_number IS NULL) OR ((limit_phone_number)::text = ‘’::text) OR ((limit_phone_number)::text = ‘902772225’::text))
  • Heap Blocks: exact=4
15. 0.101 0.101 ↓ 1.9 44 1

Bitmap Index Scan on user_coupons_user_id_idx (cost=0.00..4.45 rows=23 width=0) (actual time=0.101..0.101 rows=44 loops=1)

  • Index Cond: (user_id = 9,552,678)
16. 0.646 0.646 ↓ 0.0 0 38

Index Scan using promotions_pkey on promotions (cost=0.28..0.41 rows=1 width=16) (actual time=0.016..0.017 rows=0 loops=38)

  • Index Cond: (id = promotion_usages.promotion_id)
  • Filter: ((active_from < ‘2020-07-31 15:03:00.686827+07’::timestamp with time zone) AND (‘2020-07-31 15:03:00.686827+07’::timestamp with time zone < active_to) AND (max_active_times > promotion_usages.active_times))
  • Rows Removed by Filter: 1
17. 0.111 0.111 ↑ 6.0 1 3

Seq Scan on user_promotion_daily_usages (cost=0.00..33.20 rows=6 width=12) (actual time=0.036..0.037 rows=1 loops=3)

  • Filter: ((created_at)::date = (‘now’::cstring)::date)
  • Rows Removed by Filter: 1
Planning time : 13.647 ms
Execution time : 14.783 ms