explain.depesz.com

PostgreSQL's explain analyze made readable

Result: A7JR

Settings
# exclusive inclusive rows x rows loops node
1. 0.063 4.968 ↓ 11.0 11 1

Hash Join (cost=18.62..28.84 rows=1 width=8) (actual time=2.098..4.968 rows=11 loops=1)

  • Hash Cond: ((modules.id = training_records.module_id) AND ((SubPlan 1) = training_records.id))
  • Join Filter: ((modules.never_expires IS TRUE) OR (modules.expiration_months = 0) OR (((training_records.created_at)::date + (((modules.expiration_months)::text || ' months'::text))::interval) > CURRENT_DATE))
  • Rows Removed by Join Filter: 8
2. 0.018 0.018 ↓ 2.0 24 1

Seq Scan on modules (cost=0.00..2.24 rows=12 width=9) (actual time=0.007..0.018 rows=24 loops=1)

  • Filter: (active IS TRUE)
3. 0.009 0.028 ↑ 1.0 38 1

Hash (cost=18.05..18.05 rows=38 width=16) (actual time=0.028..0.028 rows=38 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
4. 0.011 0.019 ↑ 1.0 38 1

Bitmap Heap Scan on training_records (cost=4.57..18.05 rows=38 width=16) (actual time=0.012..0.019 rows=38 loops=1)

  • Recheck Cond: (user_id = 769)
  • Heap Blocks: exact=2
5. 0.008 0.008 ↑ 1.0 38 1

Bitmap Index Scan on training_records_user_id_index (cost=0.00..4.56 rows=38 width=0) (actual time=0.008..0.008 rows=38 loops=1)

  • Index Cond: (user_id = 769)
6.          

SubPlan (forHash Join)

7. 0.129 4.859 ↑ 1.0 1 43

Aggregate (cost=13.18..13.19 rows=1 width=4) (actual time=0.113..0.113 rows=1 loops=43)

8. 0.215 4.730 ↓ 2.0 2 43

Bitmap Heap Scan on training_records training_records_1 (cost=9.17..13.18 rows=1 width=4) (actual time=0.108..0.110 rows=2 loops=43)

  • Recheck Cond: ((deleted_at IS NULL) AND (user_id = 769))
  • Filter: (module_id = modules.id)
  • Rows Removed by Filter: 36
  • Heap Blocks: exact=86
9. 0.086 4.515 ↓ 0.0 0 43

BitmapAnd (cost=9.17..9.17 rows=1 width=0) (actual time=0.105..0.105 rows=0 loops=43)

10. 4.300 4.300 ↓ 196.2 1,962 43

Bitmap Index Scan on training_records_deleted_at_index (cost=0.00..4.35 rows=10 width=0) (actual time=0.100..0.100 rows=1,962 loops=43)

  • Index Cond: (deleted_at IS NULL)
11. 0.129 0.129 ↑ 1.0 38 43

Bitmap Index Scan on training_records_user_id_index (cost=0.00..4.56 rows=38 width=0) (actual time=0.003..0.003 rows=38 loops=43)

  • Index Cond: (user_id = 769)
Planning time : 0.797 ms
Execution time : 5.035 ms