explain.depesz.com

PostgreSQL's explain analyze made readable

Result: hPxe

Settings
# exclusive inclusive rows x rows loops node
1. 0.028 21.128 ↑ 1.0 1 1

Aggregate (cost=3,545.80..3,545.81 rows=1 width=8) (actual time=21.128..21.128 rows=1 loops=1)

2. 0.356 21.100 ↑ 38.2 450 1

HashAggregate (cost=3,158.76..3,330.78 rows=17,202 width=4) (actual time=20.952..21.100 rows=450 loops=1)

  • Group Key: action_required_actionrequired.client_id
3. 1.037 20.744 ↑ 22.0 1,064 1

Hash Join (cost=240.62..3,100.17 rows=23,436 width=4) (actual time=1.253..20.744 rows=1,064 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:56:57.314224'::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:56:57.314224'::timestamp without time zone) AND (hashed SubPlan 2)))
  • Rows Removed by Join Filter: 1819
4. 18.702 18.732 ↑ 8.2 2,883 1

Index Scan using tmp_ar_completed_ctype on action_required_actionrequired (cost=7.32..2,804.32 rows=23,761 width=17) (actual time=0.060..18.732 rows=2,883 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:56:57.314224'::timestamp without time zone)) AND (hashed SubPlan 1)) OR ((NOT is_handed_off) AND (created_at >= '2020-05-19 20:56:57.314224'::timestamp without time zone))))
  • Rows Removed by Filter: 49132
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.007..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.154 0.959 ↑ 1.0 1,489 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 70kB
10. 0.805 0.805 ↑ 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.805 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.008..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.003..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 : 1.065 ms
Execution time : 21.277 ms