explain.depesz.com

PostgreSQL's explain analyze made readable

Result: qhN5

Settings
# exclusive inclusive rows x rows loops node
1. 0.041 40.413 ↑ 1.0 1 1

Aggregate (cost=5,451.62..5,451.63 rows=1 width=8) (actual time=40.413..40.413 rows=1 loops=1)

2. 0.543 40.372 ↑ 37.7 446 1

HashAggregate (cost=5,073.42..5,241.51 rows=16,809 width=4) (actual time=40.171..40.372 rows=446 loops=1)

  • Group Key: action_required_actionrequired.client_id
3. 1.681 39.829 ↑ 21.5 1,054 1

Hash Join (cost=240.38..5,016.86 rows=22,624 width=4) (actual time=2.049..39.829 rows=1,054 loops=1)

  • Hash Cond: (action_required_actionrequired.site_team_group_id = accounts_employeegroup.id)
  • Join Filter: (((action_required_actionrequired.is_handed_off OR (action_required_actionrequired.created_at < '2020-05-19 19:48:26.444049'::timestamp without time zone)) AND (hashed SubPlan 1)) OR ((NOT action_required_actionrequired.is_handed_off) AND (action_required_actionrequired.created_at > '2020-05-19 19:48:26.444049'::timestamp without time zone) AND (hashed SubPlan 2)))
  • Rows Removed by Join Filter: 2151
4. 36.483 36.525 ↑ 7.2 3,205 1

Seq Scan on action_required_actionrequired (cost=6.90..4,722.84 rows=22,998 width=17) (actual time=0.065..36.525 rows=3,205 loops=1)

  • Filter: ((NOT action_completed) AND (polymorphic_ctype_id = 317) AND (((is_handed_off OR (created_at < '2020-05-19 19:48:26.444049'::timestamp without time zone)) AND (hashed SubPlan 1)) OR ((NOT is_handed_off) AND (created_at > '2020-05-19 19:48:26.444049'::timestamp without time zone))))
  • Rows Removed by Filter: 155339
5.          

SubPlan (for Seq Scan)

6. 0.002 0.042 ↓ 3.0 6 2

Nested Loop (cost=0.56..6.90 rows=2 width=4) (actual time=0.009..0.021 rows=6 loops=2)

7. 0.016 0.016 ↓ 3.0 6 2

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1 (cost=0.29..3.00 rows=2 width=4) (actual time=0.005..0.008 rows=6 loops=2)

  • Index Cond: (user_id = 30867)
8. 0.024 0.024 ↑ 1.0 1 12

Index Only Scan using accounts_employeegroup_pkey on accounts_employeegroup u0 (cost=0.28..1.95 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=12)

  • Index Cond: (id = u1.employeegroup_id)
  • Heap Fetches: 0
9. 0.299 1.595 ↑ 1.0 1,489 1

Hash (cost=200.97..200.97 rows=1,497 width=8) (actual time=1.595..1.595 rows=1,489 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 70kB
10. 1.296 1.296 ↑ 1.0 1,489 1

Seq Scan on accounts_employeegroup (cost=0.00..200.97 rows=1,497 width=8) (actual time=0.004..1.296 rows=1,489 loops=1)

11.          

SubPlan (for Hash Join)

12. 0.006 0.028 ↓ 3.0 6 1

Nested Loop (cost=0.56..6.90 rows=2 width=4) (actual time=0.015..0.028 rows=6 loops=1)

13. 0.010 0.010 ↓ 3.0 6 1

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1_1 (cost=0.29..3.00 rows=2 width=4) (actual time=0.007..0.010 rows=6 loops=1)

  • Index Cond: (user_id = 30867)
14. 0.012 0.012 ↑ 1.0 1 6

Index Only Scan using accounts_employeegroup_pkey on accounts_employeegroup u0_1 (cost=0.28..1.95 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=6)

  • Index Cond: (id = u1_1.employeegroup_id)
  • Heap Fetches: 0
Planning time : 1.009 ms
Execution time : 40.854 ms