explain.depesz.com

PostgreSQL's explain analyze made readable

Result: eiek

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Sort (cost=1,622.36..1,622.86 rows=200 width=120) (actual rows= loops=)

  • Sort Key: groups.category
2.          

CTE ranged

3. 0.000 0.000 ↓ 0.0

Seq Scan on availabilities a (cost=0.00..1,449.81 rows=522 width=69) (actual rows= loops=)

  • Filter: (((depot)::text = 'lisbon'::text) AND ((('2019-11-05 00:00:00'::timestamp without time zone >= start_date) AND ('2019-11-05 00:00:00'::timestamp without time zone <= end_date)) OR (('2019-11-18 00:00:00'::timestamp without time zone >= start_date) AND ('2019-11-18 00:00:00'::timestamp without time zone <= end_date)) OR ((start_date >= '2019-11-05 00:00:00'::timestamp without time zone) AND (start_date <= '2019-11-18 00:00:00'::timestamp without time zone)) OR ((end_date >= '2019-11-18 00:00:00'::timestamp without time zone) AND (end_date <= '2019-11-18 00:00:00'::timestamp without time zone))))
4.          

CTE minmax

5. 0.000 0.000 ↓ 0.0

WindowAgg (cost=35.15..46.83 rows=519 width=116) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Sort (cost=35.15..36.45 rows=519 width=100) (actual rows= loops=)

  • Sort Key: ranged.range
7. 0.000 0.000 ↓ 0.0

CTE Scan on ranged (cost=0.00..11.74 rows=519 width=100) (actual rows= loops=)

  • Filter: (range <> 'empty'::tsrange)
8.          

CTE lag

9. 0.000 0.000 ↓ 0.0

WindowAgg (cost=33.79..42.87 rows=519 width=124) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Sort (cost=33.79..35.08 rows=519 width=116) (actual rows= loops=)

  • Sort Key: minmax.range
11. 0.000 0.000 ↓ 0.0

CTE Scan on minmax (cost=0.00..10.38 rows=519 width=116) (actual rows= loops=)

12.          

CTE lagstep

13. 0.000 0.000 ↓ 0.0

CTE Scan on lag (cost=0.00..11.68 rows=519 width=125) (actual rows= loops=)

14.          

CTE groups

15. 0.000 0.000 ↓ 0.0

WindowAgg (cost=33.79..42.87 rows=519 width=133) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Sort (cost=33.79..35.08 rows=519 width=125) (actual rows= loops=)

  • Sort Key: lagstep.range
17. 0.000 0.000 ↓ 0.0

CTE Scan on lagstep (cost=0.00..10.38 rows=519 width=125) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

HashAggregate (cost=18.16..20.66 rows=200 width=120) (actual rows= loops=)

  • Group Key: groups.category, groups.depot, groups.grp
19. 0.000 0.000 ↓ 0.0

CTE Scan on groups (cost=0.00..10.38 rows=519 width=92) (actual rows= loops=)