explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZAaQ3

Settings
# exclusive inclusive rows x rows loops node
1. 0.715 13,224.983 ↑ 1.0 1 1

Aggregate (cost=85,736.28..85,736.29 rows=1 width=8) (actual time=13,224.972..13,224.983 rows=1 loops=1)

2. 3.196 13,224.268 ↑ 755.1 108 1

HashAggregate (cost=83,901.36..84,716.88 rows=81,552 width=4) (actual time=13,222.990..13,224.268 rows=108 loops=1)

  • Group Key: action_required_actionrequired.client_id
3. 3.963 13,221.072 ↑ 542.1 248 1

Hash Join (cost=63,750.14..83,565.24 rows=134,451 width=4) (actual time=13,029.966..13,221.072 rows=248 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))
4. 12.167 13,189.744 ↑ 542.1 248 1

Hash Join (cost=63,461.48..82,922.34 rows=134,452 width=17) (actual time=13,002.429..13,189.744 rows=248 loops=1)

  • Hash Cond: (action_required_actionrequired.client_id = clients_client.id)
5. 183.267 201.590 ↑ 166.8 970 1

Bitmap Heap Scan on action_required_actionrequired (cost=4,660.99..23,697.21 rows=161,767 width=17) (actual time=20.075..201.590 rows=970 loops=1)

  • Recheck Cond: (((NOT action_completed) AND (polymorphic_ctype_id = 317)) OR (polymorphic_ctype_id = 339))
  • Filter: ((NOT action_completed) 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: 230,565
  • Heap Blocks: exact=13,584
6. 0.015 17.213 ↓ 0.0 0 1

BitmapOr (cost=4,610.64..4,610.64 rows=215,689 width=0) (actual time=17.208..17.213 rows=0 loops=1)

7. 17.158 17.158 ↓ 1.1 231,523 1

Bitmap Index Scan on action_required_actionre_action_completed_polymor_bc9ca40d_idx (cost=0.00..4,525.32 rows=215,689 width=0) (actual time=17.152..17.158 rows=231,523 loops=1)

  • Index Cond: ((action_completed = false) AND (polymorphic_ctype_id = 317))
8. 0.040 0.040 ↓ 12.0 12 1

Bitmap Index Scan on action_required_actionrequired_polymorphic_ctype_id_2454fb9d (cost=0.00..4.44 rows=1 width=0) (actual time=0.035..0.040 rows=12 loops=1)

  • Index Cond: (polymorphic_ctype_id = 339)
9.          

SubPlan (for Bitmap Heap Scan)

10. 0.092 0.262 ↑ 1.0 2 2

Nested Loop (cost=0.56..28.08 rows=2 width=4) (actual time=0.071..0.131 rows=2 loops=2)

11. 0.086 0.086 ↑ 1.0 2 2

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

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

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

  • Index Cond: (id = u1.employeegroup_id)
  • Heap Fetches: 4
13. 0.389 0.848 ↓ 0.0 0 1

Nested Loop (cost=0.56..22.26 rows=1 width=4) (actual time=0.837..0.848 rows=0 loops=1)

  • Join Filter: (u0_2.id = u1_2.employeegroup_id)
  • Rows Removed by Join Filter: 18
14. 0.207 0.207 ↑ 1.0 9 1

Index Scan using accounts_employeegroup_team_type_a13504aa on accounts_employeegroup u0_2 (cost=0.28..10.50 rows=9 width=4) (actual time=0.029..0.207 rows=9 loops=1)

  • Index Cond: (team_type = 20)
15. 0.213 0.252 ↑ 1.0 2 9

Materialize (cost=0.29..11.49 rows=2 width=4) (actual time=0.009..0.028 rows=2 loops=9)

16. 0.039 0.039 ↑ 1.0 2 1

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1_2 (cost=0.29..11.48 rows=2 width=4) (actual time=0.015..0.039 rows=2 loops=1)

  • Index Cond: (user_id = 30,782)
17. 6,143.661 12,975.987 ↑ 1.0 848,947 1

Hash (cost=48,088.63..48,088.63 rows=856,949 width=4) (actual time=12,975.981..12,975.987 rows=848,947 loops=1)

  • Buckets: 1,048,576 Batches: 1 Memory Usage: 38,038kB
18. 6,832.326 6,832.326 ↑ 1.0 848,947 1

Seq Scan on clients_client (cost=0.00..48,088.63 rows=856,949 width=4) (actual time=1.902..6,832.326 rows=848,947 loops=1)

  • Filter: ((status <> ALL ('{50,70}'::integer[])) AND (status <> 80))
  • Rows Removed by Filter: 182,059
19. 12.432 27.365 ↑ 1.0 1,832 1

Hash (cost=187.32..187.32 rows=1,832 width=8) (actual time=27.360..27.365 rows=1,832 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 82kB
20. 14.933 14.933 ↑ 1.0 1,832 1

Seq Scan on accounts_employeegroup (cost=0.00..187.32 rows=1,832 width=8) (actual time=0.034..14.933 rows=1,832 loops=1)

21.          

SubPlan (for Hash Join)

22. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..28.08 rows=2 width=4) (never executed)

23. 0.000 0.000 ↓ 0.0 0

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1_1 (cost=0.29..11.48 rows=2 width=4) (never executed)

  • Index Cond: (user_id = 30,782)
24. 0.000 0.000 ↓ 0.0 0

Index Only Scan using accounts_employeegroup_pkey on accounts_employeegroup u0_1 (cost=0.28..8.29 rows=1 width=4) (never executed)

  • Index Cond: (id = u1_1.employeegroup_id)
  • Heap Fetches: 0
Planning time : 4.206 ms
Execution time : 13,228.957 ms