explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 3MT3 : kjh

Settings

Optimization(s) for this plan:

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

Nested Loop (cost=4,956,923.86..4,957,092.83 rows=20 width=79) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Limit (cost=4,956,923.43..4,956,923.78 rows=20 width=69) (actual rows= loops=)

3.          

Initplan (forLimit)

4. 0.000 0.000 ↓ 0.0

Index Scan using users_pkey on users users_1 (cost=0.42..8.44 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = 373)
5. 0.000 0.000 ↓ 0.0

Unique (cost=4,956,914.99..5,131,915.01 rows=10,000,001 width=69) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Sort (cost=4,956,914.99..4,981,914.99 rows=10,000,001 width=69) (actual rows= loops=)

  • Sort Key: events.created_at DESC, events.name, events.id, events.description, events.author_id, (count(*) FILTER (WHERE (event_attendances.id IS NOT NULL)))
7. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=1,743,738.01..2,563,766.03 rows=10,000,001 width=69) (actual rows= loops=)

  • Group Key: events.id
8. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=1,743,738.01..2,413,766.02 rows=10,000,001 width=69) (actual rows= loops=)

  • Merge Cond: (events.id = events_gender_filters.event_id)
  • Filter: ((NOT events.is_filter) OR (events_gender_filters.gender_id = $0))
9. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=134,102.39..579,145.18 rows=10,000,001 width=70) (actual rows= loops=)

  • Merge Cond: (events.id = event_attendances.event_id)
10. 0.000 0.000 ↓ 0.0

Index Scan using events_pkey on events (cost=0.43..402,544.45 rows=10,000,001 width=62) (actual rows= loops=)

11. 0.000 0.000 ↓ 0.0

Materialize (cost=134,101.46..139,101.46 rows=1,000,001 width=12) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Sort (cost=134,101.46..136,601.46 rows=1,000,001 width=12) (actual rows= loops=)

  • Sort Key: event_attendances.event_id
13. 0.000 0.000 ↓ 0.0

Seq Scan on event_attendances (cost=0.00..17,353.01 rows=1,000,001 width=12) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Materialize (cost=1,609,630.62..1,659,630.05 rows=9,999,886 width=8) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Sort (cost=1,609,630.62..1,634,630.33 rows=9,999,886 width=8) (actual rows= loops=)

  • Sort Key: events_gender_filters.event_id
16. 0.000 0.000 ↓ 0.0

Seq Scan on events_gender_filters (cost=0.00..173,528.86 rows=9,999,886 width=8) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Index Scan using users_pkey on users (cost=0.42..8.44 rows=1 width=18) (actual rows= loops=)

  • Index Cond: (id = events.author_id)