explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5rmC

Settings
# exclusive inclusive rows x rows loops node
1. 0.029 25.196 ↑ 1.0 1 1

Aggregate (cost=3,545.40..3,545.41 rows=1 width=8) (actual time=25.196..25.196 rows=1 loops=1)

2. 0.376 25.167 ↑ 38.3 446 1

HashAggregate (cost=3,160.88..3,331.78 rows=17,090 width=4) (actual time=25.017..25.167 rows=446 loops=1)

  • Group Key: action_required_actionrequired.client_id
3. 1.163 24.791 ↑ 22.1 1,057 1

Hash Join (cost=240.62..3,102.59 rows=23,316 width=4) (actual time=4.293..24.791 rows=1,057 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: 2001
4. 19.660 20.702 ↑ 7.7 3,058 1

Index Scan using tmp_ar_completed_ctype on action_required_actionrequired (cost=7.32..2,807.00 rows=23,664 width=17) (actual time=1.095..20.702 rows=3,058 loops=1)

  • Index Cond: ((action_completed = false) AND (polymorphic_ctype_id = 317))
  • Filter: ((NOT action_completed) 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: 48957
5.          

SubPlan (for Index Scan)

6. 0.002 1.042 ↓ 3.0 6 2

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

7. 0.992 0.992 ↓ 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.252..0.496 rows=6 loops=2)

  • Index Cond: (user_id = 30867)
8. 0.048 0.048 ↑ 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.003..0.004 rows=1 loops=12)

  • Index Cond: (id = u1.employeegroup_id)
  • Heap Fetches: 2
9. 0.169 2.902 ↑ 1.0 1,489 1

Hash (cost=200.89..200.89 rows=1,489 width=8) (actual time=2.902..2.902 rows=1,489 loops=1)

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

Seq Scan on accounts_employeegroup (cost=0.00..200.89 rows=1,489 width=8) (actual time=0.009..2.733 rows=1,489 loops=1)

11.          

SubPlan (for Hash Join)

12. 0.006 0.024 ↓ 3.0 6 1

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

13. 0.012 0.012 ↓ 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.009..0.012 rows=6 loops=1)

  • Index Cond: (user_id = 30867)
14. 0.006 0.006 ↑ 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.001..0.001 rows=1 loops=6)

  • Index Cond: (id = u1_1.employeegroup_id)
  • Heap Fetches: 1
Planning time : 431.425 ms
Execution time : 25.359 ms