explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kX4l

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Sort (cost=855,988.77..855,988.78 rows=5 width=65) (actual rows= loops=)

  • Sort Key: w.userid, w.username
2.          

CTE cte_org

3. 0.000 0.000 ↓ 0.0

Result (cost=0.00..0.01 rows=1 width=40) (actual rows= loops=)

4.          

CTE ev_ids

5. 0.000 0.000 ↓ 0.0

Append (cost=103.13..43,135.30 rows=10,028 width=8) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on evs evs_1 (cost=103.13..6,062.44 rows=4,927 width=8) (actual rows= loops=)

  • Recheck Cond: (company_id = $1)
7.          

Initplan (for Bitmap Heap Scan)

8. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on evs_company_id_idx (cost=0.00..101.88 rows=4,927 width=0) (actual rows= loops=)

  • Index Cond: (company_id = $1)
10. 0.000 0.000 ↓ 0.0

Gather (cost=1,000.02..36,922.44 rows=5,101 width=8) (actual rows= loops=)

  • Workers Planned: 4
  • Params Evaluated: $2
11.          

Initplan (for Gather)

12. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org cte_org_1 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on evs_arc evs_arc_1 (cost=0.00..35,412.32 rows=1,275 width=8) (actual rows= loops=)

  • Filter: (company_id = $2)
14. 0.000 0.000 ↓ 0.0

HashAggregate (cost=812,850.20..812,853.35 rows=5 width=65) (actual rows= loops=)

  • Group Key: w.userid, w.username
  • Filter: ((max(w.last_login) IS NULL) OR (max("*SELECT* 1_1".max_date) IS NULL) OR (max(("*SELECT* 1".creation_date)::date) IS NULL))
15. 0.000 0.000 ↓ 0.0

Merge Right Join (cost=313,807.14..489,988.13 rows=11,740,439 width=69) (actual rows= loops=)

  • Merge Cond: ("*SELECT* 1_1".person_id = w.person_id)
16. 0.000 0.000 ↓ 0.0

Sort (cost=231,346.76..231,383.96 rows=14,881 width=12) (actual rows= loops=)

  • Sort Key: "*SELECT* 1_1".person_id
17. 0.000 0.000 ↓ 0.0

Append (cost=60,297.79..230,315.42 rows=14,881 width=12) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 1_1 (cost=60,297.79..60,502.35 rows=10,228 width=12) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

HashAggregate (cost=60,297.79..60,400.07 rows=10,228 width=28) (actual rows= loops=)

  • Group Key: audit_evs_all.ntfn_id, audit_evs_all.person_id, audit_evs_all.dvc_id
20.          

Initplan (for HashAggregate)

21. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org cte_org_5 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Nested Loop (cost=226.19..60,169.92 rows=10,228 width=32) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

HashAggregate (cost=225.63..227.63 rows=200 width=8) (actual rows= loops=)

  • Group Key: ev_ids.ev_id
24. 0.000 0.000 ↓ 0.0

CTE Scan on ev_ids (cost=0.00..200.56 rows=10,028 width=8) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Index Scan using idx_audit_evs_all_eia on audit_evs_all (cost=0.56..299.70 rows=1 width=40) (actual rows= loops=)

  • Index Cond: ((ev_id = ev_ids.ev_id) AND ((ap_audit_ev_type)::text = ANY ('{LIVE_NOTIFICATION_PROVIDER_DELIVERED,LIVE_NOTIFICATION_DEVICE_DELIVERED,LIVE_NOTIFICATION_DEVICE_READ}'::text[])))
  • Filter: (org_id = $8)
26. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 2_1 (cost=169,575.81..169,738.67 rows=4,653 width=12) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=169,575.81..169,692.14 rows=4,653 width=28) (actual rows= loops=)

  • Group Key: audit_evs_all_arc.ntfn_id, audit_evs_all_arc.person_id, audit_evs_all_arc.dvc_id
28.          

Initplan (for GroupAggregate)

29. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org cte_org_6 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Sort (cost=169,575.79..169,587.42 rows=4,653 width=32) (actual rows= loops=)

  • Sort Key: audit_evs_all_arc.ntfn_id, audit_evs_all_arc.person_id, audit_evs_all_arc.dvc_id
31. 0.000 0.000 ↓ 0.0

Nested Loop (cost=226.19..169,292.33 rows=4,653 width=32) (actual rows= loops=)

32. 0.000 0.000 ↓ 0.0

HashAggregate (cost=225.63..227.63 rows=200 width=8) (actual rows= loops=)

  • Group Key: ev_ids_1.ev_id
33. 0.000 0.000 ↓ 0.0

CTE Scan on ev_ids ev_ids_1 (cost=0.00..200.56 rows=10,028 width=8) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Index Scan using idx_audit_proc_evs_arc_evid on audit_evs_all_arc (cost=0.56..845.31 rows=1 width=40) (actual rows= loops=)

  • Index Cond: (ev_id = ev_ids_1.ev_id)
  • Filter: ((org_id = $9) AND ((ap_audit_ev_type)::text = ANY ('{LIVE_NOTIFICATION_PROVIDER_DELIVERED,LIVE_NOTIFICATION_DEVICE_DELIVERED,LIVE_NOTIFICATION_DEVICE_READ}'::text[])))
35. 0.000 0.000 ↓ 0.0

Sort (cost=82,460.38..82,854.86 rows=157,791 width=73) (actual rows= loops=)

  • Sort Key: w.person_id
36. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=66,454.38..68,836.98 rows=157,791 width=73) (actual rows= loops=)

  • Merge Cond: ((w.userid)::text = ("*SELECT* 1".sender)::text)
37. 0.000 0.000 ↓ 0.0

Sort (cost=22,652.64..22,660.50 rows=3,147 width=65) (actual rows= loops=)

  • Sort Key: w.userid
38. 0.000 0.000 ↓ 0.0

Subquery Scan on w (cost=22,005.23..22,469.80 rows=3,147 width=65) (actual rows= loops=)

39. 0.000 0.000 ↓ 0.0

Finalize GroupAggregate (cost=22,005.23..22,438.33 rows=3,147 width=73) (actual rows= loops=)

  • Group Key: r.recipient_id, p.person_id, ((((p.first_name)::text || ' '::text) || (p.last_name)::text)), ((p.when_created)::date)
40.          

Initplan (for Finalize GroupAggregate)

41. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org cte_org_2 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Gather Merge (cost=22,005.21..22,350.46 rows=2,622 width=73) (actual rows= loops=)

  • Workers Planned: 2
  • Params Evaluated: $5
43. 0.000 0.000 ↓ 0.0

Partial GroupAggregate (cost=21,005.19..21,047.79 rows=1,311 width=73) (actual rows= loops=)

  • Group Key: r.recipient_id, p.person_id, ((((p.first_name)::text || ' '::text) || (p.last_name)::text)), ((p.when_created)::date)
44. 0.000 0.000 ↓ 0.0

Sort (cost=21,005.19..21,008.46 rows=1,311 width=73) (actual rows= loops=)

  • Sort Key: r.recipient_id, p.person_id, ((((p.first_name)::text || ' '::text) || (p.last_name)::text)), ((p.when_created)::date)
45. 0.000 0.000 ↓ 0.0

Nested Loop (cost=159.59..20,937.30 rows=1,311 width=73) (actual rows= loops=)

46. 0.000 0.000 ↓ 0.0

Nested Loop (cost=159.17..19,934.75 rows=2,161 width=29) (actual rows= loops=)

47. 0.000 0.000 ↓ 0.0

Parallel Bitmap Heap Scan on recipients r (cost=158.74..10,527.13 rows=3,350 width=21) (actual rows= loops=)

  • Recheck Cond: ((org_id = $5) AND (deleted_id = '-1'::integer))
48. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_recipients_del_org_id_cat (cost=0.00..156.73 rows=8,040 width=0) (actual rows= loops=)

  • Index Cond: (org_id = $5)
49. 0.000 0.000 ↓ 0.0

Index Scan using dvc_pk on dvc d (cost=0.43..2.81 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (dvc_id = r.recipient_id)
50. 0.000 0.000 ↓ 0.0

Index Scan using idx_persons_person_id_not_deleted on persons p (cost=0.42..0.46 rows=1 width=40) (actual rows= loops=)

  • Index Cond: (person_id = d.person_id)
51. 0.000 0.000 ↓ 0.0

Sort (cost=43,801.75..43,826.82 rows=10,028 width=20) (actual rows= loops=)

  • Sort Key: "*SELECT* 1".sender
52. 0.000 0.000 ↓ 0.0

Append (cost=103.13..43,135.30 rows=10,028 width=20) (actual rows= loops=)

53. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 1 (cost=103.13..6,111.71 rows=4,927 width=20) (actual rows= loops=)

54. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on evs (cost=103.13..6,062.44 rows=4,927 width=20) (actual rows= loops=)

  • Recheck Cond: (company_id = $6)
55.          

Initplan (for Bitmap Heap Scan)

56. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org cte_org_3 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

57. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on evs_company_id_idx (cost=0.00..101.88 rows=4,927 width=0) (actual rows= loops=)

  • Index Cond: (company_id = $6)
58. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 2 (cost=1,000.02..36,973.45 rows=5,101 width=20) (actual rows= loops=)

59. 0.000 0.000 ↓ 0.0

Gather (cost=1,000.02..36,922.44 rows=5,101 width=20) (actual rows= loops=)

  • Workers Planned: 4
  • Params Evaluated: $7
60.          

Initplan (for Gather)

61. 0.000 0.000 ↓ 0.0

CTE Scan on cte_org cte_org_4 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

62. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on evs_arc (cost=0.00..35,412.32 rows=1,275 width=20) (actual rows= loops=)

  • Filter: (company_id = $7)