explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2M6S

Settings
# exclusive inclusive rows x rows loops node
1. 3.876 3.946 ↑ 1.0 1 1

CTE Scan on prev_ts prv (cost=10.35..10.38 rows=1 width=33) (actual time=3.945..3.946 rows=1 loops=1)

2.          

CTE next_ts

3. 0.002 3.810 ↑ 1.0 1 1

Limit (cost=0.42..6.90 rows=1 width=12) (actual time=3.809..3.810 rows=1 loops=1)

4. 3.808 3.808 ↑ 1,480.0 1 1

Index Scan using timeslot_location_id_time_status_idx1 on timeslot ts (cost=0.42..9,592.80 rows=1,480 width=12) (actual time=3.808..3.808 rows=1 loops=1)

  • Index Cond: (location_id = 21)
  • Filter: (now() < ("time" + ('00:01:00'::interval * (duration)::double precision)))
  • Rows Removed by Filter: 3,970
5.          

CTE prev_ts

6. 0.000 3.871 ↑ 1.0 1 1

Limit (cost=0.44..3.16 rows=1 width=16) (actual time=3.870..3.871 rows=1 loops=1)

7.          

Initplan (for Limit)

8. 3.814 3.814 ↑ 1.0 1 1

CTE Scan on next_ts (cost=0.00..0.02 rows=1 width=8) (actual time=3.812..3.814 rows=1 loops=1)

9. 3.869 3.869 ↑ 1,480.0 1 1

Index Scan Backward using timeslot_time_index on timeslot ts_1 (cost=0.42..4,022.41 rows=1,480 width=16) (actual time=3.869..3.869 rows=1 loops=1)

  • Index Cond: ("time" < $1)
  • Filter: ((location_id = 21) AND (item_category_id = 1) AND (status = ANY ('{PUBLISHED,BOOKED,"MARKED TO DELETE"}'::text[])))
  • Rows Removed by Filter: 32
10.          

Initplan (for CTE Scan)

11. 0.069 0.069 ↑ 1.0 1 1

CTE Scan on next_ts nxt (cost=0.00..0.28 rows=1 width=32) (actual time=0.068..0.069 rows=1 loops=1)

12. 0.001 0.001 ↑ 1.0 1 1

CTE Scan on next_ts next_ts_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=1)