explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 8gNrj

Settings
# exclusive inclusive rows x rows loops node
1. 0.010 566.365 ↑ 1.0 1 1

Aggregate (cost=90,996.53..90,996.54 rows=1 width=8) (actual time=566.365..566.365 rows=1 loops=1)

2. 0.527 566.355 ↑ 924.9 99 1

HashAggregate (cost=88,936.34..89,851.98 rows=91,564 width=4) (actual time=565.925..566.355 rows=99 loops=1)

  • Group Key: action_required_actionrequired.client_id
3. 0.887 565.828 ↑ 656.5 231 1

Hash Join (cost=62,380.35..88,557.18 rows=151,663 width=4) (actual time=439.409..565.828 rows=231 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.handoff_reference_time < '2020-08-31 15:42:44.580112'::timestamp without time zone)) AND (hashed SubPlan 1)) OR ((NOT action_required_actionrequired.is_handed_off) AND (action_required_actionrequired.handoff_reference_time >= '2020-08-31 15:42:44.580112'::timestamp without time zone) AND (hashed SubPlan 2)) OR (hashed SubPlan 3))
  • Rows Removed by Join Filter: 1,696
4. 4.476 563.614 ↑ 78.7 1,927 1

Hash Join (cost=62,089.95..87,867.05 rows=151,729 width=17) (actual time=430.149..563.614 rows=1,927 loops=1)

  • Hash Cond: (action_required_actionrequired.client_id = clients_client.id)
5. 150.041 150.157 ↑ 62.8 2,905 1

Index Scan using action_required_actionre_action_completed_polymor_bc9ca40d_idx on action_required_actionrequired (cost=14.69..25,312.76 rows=182,487 width=17) (actual time=17.641..150.157 rows=2,905 loops=1)

  • Index Cond: (action_completed = false)
  • Filter: ((NOT action_completed) AND ((polymorphic_ctype_id = 317) OR (polymorphic_ctype_id = 339)) AND (((is_handed_off OR (handoff_reference_time < '2020-08-31 15:42:44.580112'::timestamp without time zone)) AND (hashed SubPlan 1)) OR ((NOT is_handed_off) AND (handoff_reference_time >= '2020-08-31 15:42:44.580112'::timestamp without time zone)) OR (hashed SubPlan 3)))
  • Rows Removed by Filter: 290,974
6.          

SubPlan (for Index Scan)

7. 0.008 0.056 ↑ 1.0 2 2

Nested Loop (cost=0.56..7.40 rows=2 width=4) (actual time=0.025..0.028 rows=2 loops=2)

8. 0.016 0.016 ↑ 1.0 2 2

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

  • Index Cond: (user_id = 30,782)
9. 0.032 0.032 ↑ 1.0 1 4

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

  • Index Cond: (id = u1.employeegroup_id)
  • Heap Fetches: 4
10. 0.002 0.060 ↓ 0.0 0 2

Nested Loop (cost=0.56..6.86 rows=1 width=4) (actual time=0.030..0.030 rows=0 loops=2)

  • Join Filter: (u0_2.id = u1_2.employeegroup_id)
  • Rows Removed by Join Filter: 16
11. 0.026 0.026 ↑ 1.0 8 2

Index Scan using accounts_employeegroup_team_type_a13504aa on accounts_employeegroup u0_2 (cost=0.28..3.10 rows=8 width=4) (actual time=0.007..0.013 rows=8 loops=2)

  • Index Cond: (team_type = 20)
12. 0.014 0.032 ↑ 1.0 2 16

Materialize (cost=0.29..3.52 rows=2 width=4) (actual time=0.002..0.002 rows=2 loops=16)

13. 0.018 0.018 ↑ 1.0 2 1

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1_2 (cost=0.29..3.51 rows=2 width=4) (actual time=0.017..0.018 rows=2 loops=1)

  • Index Cond: (user_id = 30,782)
14. 187.203 408.981 ↓ 1.0 893,694 1

Hash (cost=50,943.29..50,943.29 rows=890,558 width=4) (actual time=408.981..408.981 rows=893,694 loops=1)

  • Buckets: 1,048,576 Batches: 1 Memory Usage: 39,611kB
15. 221.778 221.778 ↓ 1.0 893,694 1

Seq Scan on clients_client (cost=0.00..50,943.29 rows=890,558 width=4) (actual time=0.009..221.778 rows=893,694 loops=1)

  • Filter: ((status <> ALL ('{50,70}'::integer[])) AND (status <> 80))
  • Rows Removed by Filter: 192,137
16. 0.221 1.299 ↑ 1.0 1,855 1

Hash (cost=245.55..245.55 rows=1,855 width=8) (actual time=1.299..1.299 rows=1,855 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 83kB
17. 1.078 1.078 ↑ 1.0 1,855 1

Seq Scan on accounts_employeegroup (cost=0.00..245.55 rows=1,855 width=8) (actual time=0.005..1.078 rows=1,855 loops=1)

18.          

SubPlan (for Hash Join)

19. 0.002 0.028 ↑ 1.0 2 1

Nested Loop (cost=0.56..7.40 rows=2 width=4) (actual time=0.024..0.028 rows=2 loops=1)

20. 0.012 0.012 ↑ 1.0 2 1

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1_1 (cost=0.29..3.51 rows=2 width=4) (actual time=0.011..0.012 rows=2 loops=1)

  • Index Cond: (user_id = 30,782)
21. 0.014 0.014 ↑ 1.0 1 2

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

  • Index Cond: (id = u1_1.employeegroup_id)
  • Heap Fetches: 2
Planning time : 2.208 ms
Execution time : 568.667 ms