explain.depesz.com

PostgreSQL's explain analyze made readable

Result: zyd

Settings
# exclusive inclusive rows x rows loops node
1. 0.017 1,214.363 ↑ 1.0 25 1

Limit (cost=116,596.46..116,596.52 rows=25 width=140) (actual time=1,214.341..1,214.363 rows=25 loops=1)

2.          

CTE personal_prefs

3. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.84..23.12 rows=1 width=4) (never executed)

  • Filter: (COALESCE(useremailprefs_1.preference, defaultemailprefs_1.preference) = 1)
4. 0.000 0.000 ↓ 0.0 0

Index Scan using ix_defaultemailprefs_orgid on defaultemailprefs defaultemailprefs_1 (cost=0.42..14.67 rows=1 width=8) (never executed)

  • Index Cond: (orgid IS NULL)
  • Filter: (action = ANY ('{3,17,74}'::integer[]))
5. 0.000 0.000 ↓ 0.0 0

Index Scan using useremailprefs_userid_action_unique on useremailprefs useremailprefs_1 (cost=0.42..8.44 rows=1 width=8) (never executed)

  • Index Cond: ((userid = 1582576830) AND (action = defaultemailprefs_1.action))
6.          

CTE prefs

7. 43.885 1,147.647 ↓ 1,437.3 30,184 1

Merge Left Join (cost=6,267.77..19,951.23 rows=21 width=8) (actual time=125.734..1,147.647 rows=30,184 loops=1)

  • Merge Cond: (defaultemailprefs_2.action = defaultemailprefs_3.action)
  • Join Filter: (defaultemailprefs_3.groupid = invites.ownerid)
  • Rows Removed by Join Filter: 73502
  • Filter: (COALESCE(CASE WHEN ((defaultemailprefs_2.action = ANY ('{3,17,74,70,71}'::integer[])) OR (useremailprefs_3.preference = 4)) THEN COALESCE(useremailprefs_2.preference, defaultemailprefs_2.preference) ELSE useremailprefs_3.preference END, (...)
  • Rows Removed by Filter: 24
8. 13.349 1,081.365 ↓ 7.3 30,208 1

Merge Left Join (cost=6,267.35..13,418.18 rows=4,110 width=32) (actual time=125.705..1,081.365 rows=30,208 loops=1)

  • Merge Cond: (defaultemailprefs_2.action = useremailprefs_4.action)
  • Join Filter: (useremailprefs_4.groupid = invites.ownerid)
9. 27.607 1,067.981 ↓ 7.3 30,208 1

Nested Loop Left Join (cost=6,235.83..13,376.34 rows=4,110 width=28) (actual time=125.667..1,067.981 rows=30,208 loops=1)

10. 13.265 1,040.374 ↓ 7.3 30,208 1

Nested Loop (cost=6,235.54..13,316.65 rows=4,110 width=24) (actual time=125.644..1,040.374 rows=30,208 loops=1)

11. 0.039 0.153 ↓ 7.0 7 1

Nested Loop Left Join (cost=0.84..17.19 rows=1 width=12) (actual time=0.013..0.153 rows=7 loops=1)

12. 0.023 0.023 ↓ 7.0 7 1

Index Scan using ix_defaultemailprefs_action on defaultemailprefs defaultemailprefs_2 (cost=0.42..8.73 rows=1 width=8) (actual time=0.005..0.023 rows=7 loops=1)

  • Index Cond: (action IS NOT NULL)
  • Filter: ((groupid IS NULL) AND (orgid IS NULL))
  • Rows Removed by Filter: 10
13. 0.091 0.091 ↓ 0.0 0 7

Index Scan using useremailprefs_userid_action_groupidnull_unique on useremailprefs useremailprefs_2 (cost=0.42..8.44 rows=1 width=8) (actual time=0.013..0.013 rows=0 loops=7)

  • Index Cond: ((userid = 1582576830) AND (action = defaultemailprefs_2.action))
14. 110.404 1,026.956 ↓ 1.0 4,315 7

Hash Left Join (cost=6,234.69..13,258.36 rows=4,110 width=12) (actual time=125.245..146.708 rows=4,315 loops=7)

  • Hash Cond: (invites.ownerid = defaultemailprefs_4.groupid)
15. 14.825 51.723 ↓ 1.1 4,362 7

Hash Left Join (cost=101.21..6,324.37 rows=4,110 width=8) (actual time=0.979..7.389 rows=4,362 loops=7)

  • Hash Cond: (invites.ownerid = useremailprefs_5.groupid)
16. 31.668 36.883 ↓ 1.1 4,362 7

Bitmap Heap Scan on invites (cost=88.89..6,291.28 rows=4,110 width=4) (actual time=0.974..5.269 rows=4,362 loops=7)

  • Recheck Cond: (userid = 1582576830)
  • Filter: (status = 1)
  • Rows Removed by Filter: 5
  • Heap Blocks: exact=12943
17. 5.215 5.215 ↑ 1.1 4,367 7

Bitmap Index Scan on ix_invites_userid (cost=0.00..87.86 rows=4,725 width=0) (actual time=0.744..0.745 rows=4,367 loops=7)

  • Index Cond: (userid = 1582576830)
18. 0.003 0.015 ↑ 2.0 1 1

Hash (cost=12.29..12.29 rows=2 width=8) (actual time=0.015..0.015 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
19. 0.004 0.012 ↑ 2.0 1 1

Bitmap Heap Scan on useremailprefs useremailprefs_5 (cost=4.44..12.29 rows=2 width=8) (actual time=0.011..0.012 rows=1 loops=1)

  • Recheck Cond: ((userid = 1582576830) AND (action IS NULL))
  • Heap Blocks: exact=1
20. 0.008 0.008 ↑ 2.0 1 1

Bitmap Index Scan on useremailprefs_userid_action_unique (cost=0.00..4.44 rows=2 width=0) (actual time=0.007..0.008 rows=1 loops=1)

  • Index Cond: ((userid = 1582576830) AND (action IS NULL))
21. 436.520 864.829 ↑ 1.0 181,627 7

Hash (cost=3,152.76..3,152.76 rows=181,658 width=8) (actual time=123.547..123.547 rows=181,627 loops=7)

  • Buckets: 131072 Batches: 4 Memory Usage: 2809kB
22. 428.309 428.309 ↑ 1.0 181,639 7

Seq Scan on defaultemailprefs defaultemailprefs_4 (cost=0.00..3,152.76 rows=181,658 width=8) (actual time=0.007..61.187 rows=181,639 loops=7)

  • Filter: (action IS NULL)
  • Rows Removed by Filter: 37
23. 0.000 0.000 ↓ 0.0 0 30,208

Materialize (cost=0.29..8.31 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=30,208)

24. 0.016 0.016 ↓ 0.0 0 1

Index Scan using useremailprefs_userid_actionnull_groupidnull_unique on useremailprefs useremailprefs_3 (cost=0.29..8.31 rows=1 width=4) (actual time=0.015..0.016 rows=0 loops=1)

  • Index Cond: (userid = 1582576830)
25. 0.021 0.035 ↑ 7.0 1 1

Sort (cost=31.52..31.53 rows=7 width=12) (actual time=0.035..0.035 rows=1 loops=1)

  • Sort Key: useremailprefs_4.action
  • Sort Method: quicksort Memory: 25kB
26. 0.006 0.014 ↑ 7.0 1 1

Bitmap Heap Scan on useremailprefs useremailprefs_4 (cost=4.48..31.42 rows=7 width=12) (actual time=0.013..0.014 rows=1 loops=1)

  • Recheck Cond: (userid = 1582576830)
  • Heap Blocks: exact=1
27. 0.008 0.008 ↑ 7.0 1 1

Bitmap Index Scan on ix_useremailprefs_userid (cost=0.00..4.48 rows=7 width=0) (actual time=0.008..0.008 rows=1 loops=1)

  • Index Cond: (userid = 1582576830)
28. 22.397 22.397 ↑ 2.5 73,503 1

Index Scan using ix_defaultemailprefs_action on defaultemailprefs defaultemailprefs_3 (cost=0.42..6,068.56 rows=181,676 width=12) (actual time=0.010..22.397 rows=73,503 loops=1)

29. 0.042 1,214.346 ↑ 2.1 25 1

Sort (cost=96,622.11..96,622.24 rows=52 width=140) (actual time=1,214.340..1,214.346 rows=25 loops=1)

  • Sort Key: activity.created DESC
  • Sort Method: quicksort Memory: 28kB
30. 0.197 1,214.304 ↑ 2.1 25 1

Nested Loop Left Join (cost=197.75..96,620.64 rows=52 width=140) (actual time=1,157.210..1,214.304 rows=25 loops=1)

  • Filter: (((activity.action = ANY ('{3,17,74}'::integer[])) AND (hashed SubPlan 3)) OR ((activity.action <> ALL ('{3,17,74}'::integer[])) AND (SubPlan 6)))
31. 0.059 5.232 ↑ 4.2 25 1

Nested Loop (cost=197.43..95,637.40 rows=105 width=140) (actual time=5.017..5.232 rows=25 loops=1)

32. 3.749 4.668 ↑ 76.7 101 1

Bitmap Heap Scan on notification_recipients (cost=197.00..33,517.08 rows=7,744 width=28) (actual time=1.496..4.668 rows=101 loops=1)

  • Recheck Cond: (userid = 1582576830)
  • Filter: ((status <> 1) AND (email <> 1))
  • Rows Removed by Filter: 7433
  • Heap Blocks: exact=1644
33. 0.919 0.919 ↓ 1.1 11,890 1

Bitmap Index Scan on ix_notification_recipients_userid (cost=0.00..195.06 rows=10,483 width=0) (actual time=0.919..0.919 rows=11,890 loops=1)

  • Index Cond: (userid = 1582576830)
34. 0.505 0.505 ↓ 0.0 0 101

Index Scan using activity_pkey on activity (cost=0.43..8.01 rows=1 width=112) (actual time=0.004..0.005 rows=0 loops=101)

  • Index Cond: (id = notification_recipients.activityid)
  • Filter: ((created > '2019-06-02 23:14:35.699703'::timestamp without time zone) AND (delete_status = 0))
  • Rows Removed by Filter: 1
35. 0.000 0.000 ↓ 0.0 0 25

Index Scan using mentionkeys_pkey on mentionkeys (cost=0.29..0.65 rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=25)

  • Index Cond: (id = notification_recipients.mentionid)
36.          

SubPlan (forNested Loop Left Join)

37. 0.000 0.000 ↓ 0.0 0

CTE Scan on personal_prefs (cost=0.00..0.02 rows=1 width=4) (never executed)

38. 0.000 0.000 ↓ 0.0 0

Index Scan using useremailprefs_userid_action_unique on useremailprefs (cost=0.42..8.44 rows=1 width=0) (never executed)

  • Index Cond: ((userid = 1582576830) AND (action = mentionkeys.action))
  • Filter: (preference IS NULL)
39. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on useremailprefs useremailprefs_6 (cost=4.48..31.42 rows=1 width=4) (never executed)

  • Recheck Cond: (userid = 1582576830)
  • Filter: (preference IS NULL)
40. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ix_useremailprefs_userid (cost=0.00..4.48 rows=7 width=0) (never executed)

  • Index Cond: (userid = 1582576830)
41. 1,208.875 1,208.875 ↓ 6.0 6 25

CTE Scan on prefs (cost=0.00..0.47 rows=1 width=4) (actual time=6.433..48.355 rows=6 loops=25)

  • Filter: (ownerid = notification_recipients.ctxid)
  • Rows Removed by Filter: 25675
Planning time : 2.999 ms
Execution time : 1,214.931 ms