explain.depesz.com

PostgreSQL's explain analyze made readable

Result: xLr9 : Optimization for: Optimization for: bucket_quantity_held per holdable; plan #yMw8; plan #UjJR

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.011 0.075 ↑ 1.3 9 1

WindowAgg (cost=5.70..6.00 rows=12 width=152) (actual time=0.069..0.075 rows=9 loops=1)

2.          

CTE buckets

3. 0.001 0.030 ↑ 2.3 3 1

Limit (cost=2.52..2.64 rows=7 width=16) (actual time=0.028..0.030 rows=3 loops=1)

4. 0.008 0.029 ↑ 2.0 4 1

WindowAgg (cost=2.50..2.64 rows=8 width=16) (actual time=0.026..0.029 rows=4 loops=1)

5. 0.003 0.021 ↑ 2.0 4 1

Sort (cost=2.50..2.52 rows=8 width=8) (actual time=0.021..0.021 rows=4 loops=1)

  • Sort Key: holds_1.starts_at
  • Sort Method: quicksort Memory: 25kB
6. 0.006 0.018 ↑ 2.0 4 1

HashAggregate (cost=2.22..2.30 rows=8 width=8) (actual time=0.017..0.018 rows=4 loops=1)

  • Group Key: holds_1.starts_at
7. 0.001 0.012 ↑ 1.0 8 1

Append (cost=0.00..2.20 rows=8 width=8) (actual time=0.008..0.012 rows=8 loops=1)

8. 0.009 0.009 ↑ 1.0 4 1

Seq Scan on holds holds_1 (cost=0.00..1.04 rows=4 width=8) (actual time=0.008..0.009 rows=4 loops=1)

9. 0.002 0.002 ↑ 1.0 4 1

Seq Scan on holds holds_2 (cost=0.00..1.04 rows=4 width=8) (actual time=0.001..0.002 rows=4 loops=1)

10. 0.009 0.064 ↑ 1.3 9 1

Sort (cost=3.06..3.09 rows=12 width=92) (actual time=0.063..0.064 rows=9 loops=1)

  • Sort Key: buckets.bucket_starts_at, buckets.bucket_ends_at, holdings.holdable_type, holdings.holdable_id
  • Sort Method: quicksort Memory: 26kB
11. 0.005 0.055 ↑ 1.3 9 1

Nested Loop (cost=1.09..2.84 rows=12 width=92) (actual time=0.043..0.055 rows=9 loops=1)

  • Join Filter: "overlaps"(buckets.bucket_starts_at, buckets.bucket_ends_at, holds.starts_at, holds.ends_at)
  • Rows Removed by Join Filter: 6
12. 0.032 0.032 ↑ 2.3 3 1

CTE Scan on buckets (cost=0.00..0.14 rows=7 width=16) (actual time=0.029..0.032 rows=3 loops=1)

13. 0.004 0.018 ↑ 1.0 5 3

Materialize (cost=1.09..2.19 rows=5 width=76) (actual time=0.004..0.006 rows=5 loops=3)

14. 0.007 0.014 ↑ 1.0 5 1

Hash Join (cost=1.09..2.16 rows=5 width=76) (actual time=0.011..0.014 rows=5 loops=1)

  • Hash Cond: (holdings.hold_id = holds.id)
15. 0.003 0.003 ↑ 1.0 5 1

Seq Scan on holdings (cost=0.00..1.05 rows=5 width=60) (actual time=0.002..0.003 rows=5 loops=1)

16. 0.002 0.004 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=24) (actual time=0.004..0.004 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
17. 0.002 0.002 ↑ 1.0 4 1

Seq Scan on holds (cost=0.00..1.04 rows=4 width=24) (actual time=0.002..0.002 rows=4 loops=1)

Planning time : 0.241 ms
Execution time : 0.131 ms