explain.depesz.com

PostgreSQL's explain analyze made readable

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

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.011 0.073 ↑ 202.2 9 1

WindowAgg (cost=124.96..170.46 rows=1,820 width=152) (actual time=0.067..0.073 rows=9 loops=1)

2.          

CTE buckets

3. 0.001 0.025 ↑ 2.3 3 1

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

4. 0.007 0.024 ↑ 2.0 4 1

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

5. 0.003 0.017 ↑ 2.0 4 1

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

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

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

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

Append (cost=0.00..2.20 rows=8 width=8) (actual time=0.003..0.007 rows=8 loops=1)

8. 0.004 0.004 ↑ 1.0 4 1

Seq Scan on holds holds_1 (cost=0.00..1.04 rows=4 width=8) (actual time=0.003..0.004 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.062 ↑ 202.2 9 1

Sort (cost=122.32..126.87 rows=1,820 width=92) (actual time=0.062..0.062 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.007 0.053 ↑ 202.2 9 1

Hash Join (cost=1.72..23.77 rows=1,820 width=92) (actual time=0.050..0.053 rows=9 loops=1)

  • Hash Cond: (holdings.hold_id = holds.id)
12. 0.007 0.007 ↑ 156.0 5 1

Seq Scan on holdings (cost=0.00..17.80 rows=780 width=60) (actual time=0.006..0.007 rows=5 loops=1)

13. 0.003 0.039 ↑ 1.5 6 1

Hash (cost=1.61..1.61 rows=9 width=40) (actual time=0.039..0.039 rows=6 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
14. 0.006 0.036 ↑ 1.5 6 1

Nested Loop (cost=0.00..1.61 rows=9 width=40) (actual time=0.028..0.036 rows=6 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
15. 0.027 0.027 ↑ 2.3 3 1

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

16. 0.001 0.003 ↑ 1.0 4 3

Materialize (cost=0.00..1.06 rows=4 width=24) (actual time=0.001..0.001 rows=4 loops=3)

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 : 2.653 ms
Execution time : 0.136 ms