explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1GiO

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

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

2. 0.370 21.388 ↑ 38.2 447 1

HashAggregate (cost=3,160.91..3,331.80 rows=17,089 width=4) (actual time=21.233..21.388 rows=447 loops=1)

  • Group Key: action_required_actionrequired.client_id
3. 1.087 21.018 ↑ 22.0 1,058 1

Hash Join (cost=240.62..3,102.59 rows=23,328 width=4) (actual time=1.304..21.018 rows=1,058 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 20:13:12.768907'::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 20:13:12.768907'::timestamp without time zone) AND (hashed SubPlan 2)))
  • Rows Removed by Join Filter: 1948
4. 18.884 18.914 ↑ 7.9 3,006 1

Index Scan using tmp_ar_completed_ctype on action_required_actionrequired (cost=7.32..2,807.00 rows=23,663 width=17) (actual time=0.063..18.914 rows=3,006 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 20:13:12.768907'::timestamp without time zone)) AND (hashed SubPlan 1)) OR ((NOT is_handed_off) AND (created_at > '2020-05-19 20:13:12.768907'::timestamp without time zone))))
  • Rows Removed by Filter: 49009
5.          

SubPlan (for Index Scan)

6. 0.008 0.030 ↓ 3.0 6 2

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

7. 0.010 0.010 ↓ 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.003..0.005 rows=6 loops=2)

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

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

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

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

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

11.          

SubPlan (for Hash Join)

12. 0.005 0.016 ↓ 3.0 6 1

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

13. 0.005 0.005 ↓ 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.004..0.005 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 : 0.696 ms
Execution time : 21.574 ms