explain.depesz.com

PostgreSQL's explain analyze made readable

Result: CQlx

Settings
# exclusive inclusive rows x rows loops node
1. 0.017 6.525 ↑ 1.0 1 1

Aggregate (cost=338.75..338.76 rows=1 width=0) (actual time=6.524..6.525 rows=1 loops=1)

2. 0.015 6.508 ↓ 2.0 2 1

Nested Loop Left Join (cost=238.98..338.74 rows=1 width=0) (actual time=6.484..6.508 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
3. 0.862 6.427 ↓ 3.0 3 1

Hash Right Join (cost=238.98..305.45 rows=1 width=8) (actual time=6.422..6.427 rows=3 loops=1)

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

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

5. 0.004 4.560 ↓ 3.0 3 1

Hash (cost=238.97..238.97 rows=1 width=12) (actual time=4.560..4.560 rows=3 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
6. 0.158 4.556 ↓ 3.0 3 1

Hash Right Join (cost=228.98..238.97 rows=1 width=12) (actual time=4.544..4.556 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))
7. 0.156 0.156 ↓ 1.0 434 1

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

8. 0.005 4.242 ↓ 1.5 3 1

Hash (cost=228.95..228.95 rows=2 width=16) (actual time=4.242..4.242 rows=3 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 1kB
9. 0.068 4.237 ↓ 1.5 3 1

Nested Loop (cost=10.28..228.95 rows=2 width=16) (actual time=4.212..4.237 rows=3 loops=1)

  • Join Filter: (user_coupons.promotion_id = promotions.id)
10. 1.936 3.941 ↓ 3.2 38 1

Hash Join (cost=10.00..223.86 rows=12 width=12) (actual time=3.857..3.941 rows=38 loops=1)

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

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

12. 0.039 0.191 ↓ 3.2 39 1

Hash (cost=9.85..9.85 rows=12 width=8) (actual time=0.191..0.191 rows=39 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 2kB
13. 0.098 0.152 ↓ 3.2 39 1

Bitmap Heap Scan on user_coupons (cost=4.45..9.85 rows=12 width=8) (actual time=0.090..0.152 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
14. 0.054 0.054 ↓ 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.054..0.054 rows=44 loops=1)

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

Index Scan using promotions_pkey on promotions (cost=0.28..0.41 rows=1 width=16) (actual time=0.006..0.006 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
16. 0.066 0.066 ↑ 6.0 1 3

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

  • Filter: ((created_at)::date = ('now'::cstring)::date)
  • Rows Removed by Filter: 1
Planning time : 5.539 ms
Execution time : 6.876 ms