explain.depesz.com

PostgreSQL's explain analyze made readable

Result: MHnK : modified query, added timeentry.entrydate index (killed after 4 min, explain only)

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

Sort (cost=2,276,662.10..2,278,487.34 rows=730,094 width=408) (actual rows= loops=)

  • Sort Key: ((pj.code)::character varying(50)) COLLATE "en_US", ((pj.name)::character varying(255)) COLLATE "en_US", ((cl.name)::character varying(255)) COLLATE "en_US", ((tk.name)::character varying(255)) COLLATE "en_US", ((tk.code)::character varying(50)) COLLATE "en_US", ((ui.lastname)::character varying(50)) COLLATE "en_US", ((ui.firstname)::character varying(50)) COLLATE "en_US", ui.duplicatename, ((login.loginname)::character varying(255)) COLLATE "en_US", ((ui.externalid)::character varying(255)) COLLATE "en_US", ((ui.info5)::character varying(255)) COLLATE "en_US", ((dep.name)::character varying(255)) COLLATE "en_US", "*SELECT* 1".entrydate, ts.startdate, ts.enddate, tslist.timesheetstatus, ((tdh.hierarchysorting)::text) COLLATE "en_US", ((tdh.hierarchytaskname)::text) COLLATE "en_US", ((timeentrymetadata9.text)::text) COLLATE "en_US", ((userinfo10.displayname)::text) COLLATE "en_US", "*SELECT* 1".timeentryid, ((billingrate11.name)::character varying(50)) COLLATE "en_US
2.          

Initplan (forSort)

3. 0.000 0.000 ↓ 0.0

Seq Scan on systeminformation (cost=0.00..1.01 rows=1 width=4) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,831,055.40..1,936,044.25 rows=730,094 width=408) (actual rows= loops=)

  • Hash Cond: ("*SELECT* 1".billingrateid = billingrate11.id)
5. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,831,042.92..1,925,992.97 rows=730,094 width=399) (actual rows= loops=)

  • Hash Cond: (pj.projectleaderapproverid = userinfo10.id)
6. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,831,002.55..1,915,932.26 rows=730,094 width=389) (actual rows= loops=)

  • Hash Cond: ("*SELECT* 1".userid = login.userid)
7. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,830,904.36..1,905,795.27 rows=730,094 width=371) (actual rows= loops=)

  • Hash Cond: (tk.id = tdh.taskid)
8. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=1,825,496.86..1,829,524.98 rows=730,094 width=312) (actual rows= loops=)

  • Merge Cond: ("*SELECT* 1".timeentryid = timeentrymetadata9.timeentryid)
9. 0.000 0.000 ↓ 0.0

Sort (cost=1,599,380.20..1,601,205.43 rows=730,094 width=268) (actual rows= loops=)

  • Sort Key: "*SELECT* 1".timeentryid
10. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,276,519.49..1,343,610.35 rows=730,094 width=268) (actual rows= loops=)

  • Hash Cond: ("*SELECT* 1".userid = ui.id)
11. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,276,479.12..1,333,531.20 rows=730,094 width=229) (actual rows= loops=)

  • Hash Cond: (COALESCE(clients17.id, pj.clientid) = cl.id)
12. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,276,476.64..1,328,381.55 rows=730,094 width=221) (actual rows= loops=)

  • Hash Cond: (task15.id = tk.id)
13. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=1,270,329.43..1,274,357.55 rows=730,094 width=180) (actual rows= loops=)

  • Merge Cond: ("*SELECT* 1".timeentryid = timeentrymetadata16.timeentryid)
14. 0.000 0.000 ↓ 0.0

Sort (cost=1,043,865.11..1,045,690.34 rows=730,094 width=176) (actual rows= loops=)

  • Sort Key: "*SELECT* 1".timeentryid
15. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=716,616.49..847,987.27 rows=730,094 width=176) (actual rows= loops=)

  • Hash Cond: (COALESCE(project13.id, task15.projectid) = pj.id)
16. 0.000 0.000 ↓ 0.0

Hash Join (cost=716,452.12..837,784.10 rows=730,094 width=100) (actual rows= loops=)

  • Hash Cond: (ts.id = tslist.timesheetid)
17. 0.000 0.000 ↓ 0.0

Nested Loop (cost=703,453.38..789,646.56 rows=731,965 width=112) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=703,452.96..704,128.57 rows=43,969 width=84) (actual rows= loops=)

  • Merge Cond: ("*SELECT* 1".timeentryid = timeentrymetadata12.timeentryid)
19. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=476,660.49..477,053.25 rows=43,969 width=80) (actual rows= loops=)

  • Merge Cond: ("*SELECT* 1".timeentryid = timeentrymetadata14.timeentryid)
20. 0.000 0.000 ↓ 0.0

Sort (cost=244,953.02..245,062.95 rows=43,969 width=72) (actual rows= loops=)

  • Sort Key: "*SELECT* 1".timeentryid
21. 0.000 0.000 ↓ 0.0

Append (cost=38.80..239,756.09 rows=43,969 width=72) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 1 (cost=38.80..239,748.50 rows=43,952 width=72) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=38.80..239,308.98 rows=43,952 width=237) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=37.95..94,144.70 rows=1,625 width=237) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=37.52..49,342.37 rows=1,625 width=179) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Nested Loop (cost=37.08..4,564.41 rows=1,625 width=121) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..2.03 rows=1 width=65) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Seq Scan on systeminformation si (cost=0.00..1.01 rows=1 width=33) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Seq Scan on projectsysteminformation psi (cost=0.00..1.01 rows=1 width=32) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on timeentry te (cost=37.08..4,546.13 rows=1,625 width=56) (actual rows= loops=)

  • Recheck Cond: ((entrydate >= '2019-03-30'::date) AND (entrydate <= '2019-04-05'::date))
  • Filter: ((timeallocationtype <> 2) OR (timeallocationtype IS NULL))
31. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on ixtemp_teentrydate (cost=0.00..36.68 rows=1,625 width=0) (actual rows= loops=)

  • Index Cond: ((entrydate >= '2019-03-30'::date) AND (entrydate <= '2019-04-05'::date))
32. 0.000 0.000 ↓ 0.0

Index Scan using ixtemtimeentryid on timeentrymetadata tembillingrate (cost=0.43..27.55 rows=1 width=74) (actual rows= loops=)

  • Index Cond: (timeentryid = te.id)
  • Filter: (key = 'urn:replicon:time-entry-metadata-key:billing-rate'::text)
33. 0.000 0.000 ↓ 0.0

Index Scan using ixtemtimeentryid on timeentrymetadata temdbreaktype (cost=0.43..27.56 rows=1 width=74) (actual rows= loops=)

  • Index Cond: (timeentryid = te.id)
  • Filter: (upper(key) = 'URN:REPLICON:TIME-ENTRY-METADATA-KEY:BREAK-TYPE'::text)
34. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.85..87.80 rows=18 width=12) (actual rows= loops=)

35. 0.000 0.000 ↓ 0.0

Index Scan using uix2tsuseridstartdate on timesheet ts_1 (cost=0.42..5.83 rows=17 width=28) (actual rows= loops=)

  • Index Cond: ((userid = te.userid) AND (te.entrydate >= startdate))
  • Filter: (te.entrydate <= enddate)
36. 0.000 0.000 ↓ 0.0

Index Scan using ixtpsstimesheetid on timesheetpolicysettingssnapshot tspolicy (cost=0.43..4.80 rows=2 width=16) (actual rows= loops=)

  • Index Cond: (timesheetid = ts_1.id)
  • Filter: (upper(uri) = 'URN:REPLICON:POLICY:TIMESHEET:TIMESHEET-FORMAT:GEN4-TIMESHEET'::text)
37. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* 2 (cost=0.42..7.59 rows=17 width=72) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.42..7.42 rows=17 width=24) (actual rows= loops=)

39. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..2.04 rows=1 width=24) (actual rows= loops=)

  • Join Filter: (toe.timeoffid = toff.id)
40. 0.000 0.000 ↓ 0.0

Seq Scan on timeoffentries toe (cost=0.00..1.01 rows=1 width=24) (actual rows= loops=)

  • Filter: ((entrydate >= '2019-03-30'::date) AND (entrydate <= '2019-04-05'::date))
41. 0.000 0.000 ↓ 0.0

Seq Scan on timeoffs toff (cost=0.00..1.01 rows=1 width=8) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Index Only Scan using ixtsuseridstartdateenddate on timesheet ts_2 (cost=0.42..5.21 rows=17 width=12) (actual rows= loops=)

  • Index Cond: ((userid = toff.userid) AND (startdate <= toe.entrydate) AND (enddate >= toe.entrydate))
43. 0.000 0.000 ↓ 0.0

Sort (cost=231,707.47..231,787.37 rows=31,960 width=24) (actual rows= loops=)

  • Sort Key: timeentrymetadata14.timeentryid
44. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=3,880.50..229,316.22 rows=31,960 width=24) (actual rows= loops=)

  • Hash Cond: (("substring"(timeentrymetadata14.uri, '^urn:replicon-tenant:d39c603ba5ee46da9a42069eec872cf2:task:(.*)$'::text))::integer = task15.id)
45. 0.000 0.000 ↓ 0.0

Seq Scan on timeentrymetadata timeentrymetadata14 (cost=0.00..223,725.42 rows=31,960 width=74) (actual rows= loops=)

  • Filter: (upper(key) = 'URN:REPLICON:TIME-ENTRY-METADATA-KEY:TASK'::text)
46. 0.000 0.000 ↓ 0.0

Hash (cost=2,457.89..2,457.89 rows=86,689 width=8) (actual rows= loops=)

47. 0.000 0.000 ↓ 0.0

Seq Scan on task task15 (cost=0.00..2,457.89 rows=86,689 width=8) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Sort (cost=226,792.47..226,872.37 rows=31,960 width=20) (actual rows= loops=)

  • Sort Key: timeentrymetadata12.timeentryid
49. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=116.51..224,401.23 rows=31,960 width=20) (actual rows= loops=)

  • Hash Cond: (("substring"(timeentrymetadata12.uri, '^urn:replicon-tenant:d39c603ba5ee46da9a42069eec872cf2:project:(.*)$'::text))::integer = project13.id)
50. 0.000 0.000 ↓ 0.0

Seq Scan on timeentrymetadata timeentrymetadata12 (cost=0.00..223,725.42 rows=31,960 width=74) (actual rows= loops=)

  • Filter: (upper(key) = 'URN:REPLICON:TIME-ENTRY-METADATA-KEY:PROJECT'::text)
51. 0.000 0.000 ↓ 0.0

Hash (cost=81.86..81.86 rows=2,772 width=4) (actual rows= loops=)

52. 0.000 0.000 ↓ 0.0

Index Only Scan using project_pkey on project project13 (cost=0.28..81.86 rows=2,772 width=4) (actual rows= loops=)

53. 0.000 0.000 ↓ 0.0

Index Scan using ixtsuseridstartdateenddate on timesheet ts (cost=0.42..1.77 rows=17 width=28) (actual rows= loops=)

  • Index Cond: ((userid = "*SELECT* 1".userid) AND ("*SELECT* 1".entrydate >= startdate) AND ("*SELECT* 1".entrydate <= enddate))
54. 0.000 0.000 ↓ 0.0

Hash (cost=10,526.64..10,526.64 rows=134,648 width=20) (actual rows= loops=)

55. 0.000 0.000 ↓ 0.0

Seq Scan on dm_timesheetlist_facts tslist (cost=0.00..10,526.64 rows=134,648 width=20) (actual rows= loops=)

  • Filter: (timesheetstatus = ANY ('{0,1,2,3,4}'::integer[]))
56. 0.000 0.000 ↓ 0.0

Hash (cost=129.72..129.72 rows=2,772 width=84) (actual rows= loops=)

57. 0.000 0.000 ↓ 0.0

Seq Scan on project pj (cost=0.00..129.72 rows=2,772 width=84) (actual rows= loops=)

58. 0.000 0.000 ↓ 0.0

Sort (cost=226,464.32..226,544.22 rows=31,960 width=20) (actual rows= loops=)

  • Sort Key: timeentrymetadata16.timeentryid
59. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=2.49..224,073.07 rows=31,960 width=20) (actual rows= loops=)

  • Hash Cond: (("substring"(timeentrymetadata16.uri, '^urn:replicon-tenant:d39c603ba5ee46da9a42069eec872cf2:client:(.*)$'::text))::integer = clients17.id)
60. 0.000 0.000 ↓ 0.0

Seq Scan on timeentrymetadata timeentrymetadata16 (cost=0.00..223,725.42 rows=31,960 width=74) (actual rows= loops=)

  • Filter: (upper(key) = 'URN:REPLICON:TIME-ENTRY-METADATA-KEY:CLIENT'::text)
61. 0.000 0.000 ↓ 0.0

Hash (cost=1.66..1.66 rows=66 width=4) (actual rows= loops=)

62. 0.000 0.000 ↓ 0.0

Seq Scan on clients clients17 (cost=0.00..1.66 rows=66 width=4) (actual rows= loops=)

63. 0.000 0.000 ↓ 0.0

Hash (cost=4,301.60..4,301.60 rows=86,689 width=45) (actual rows= loops=)

64. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=2.44..4,301.60 rows=86,689 width=45) (actual rows= loops=)

  • Hash Cond: (tk.estimatedcostcurrencyid = exchangerate.fixedcurrencyid)
65. 0.000 0.000 ↓ 0.0

Seq Scan on task tk (cost=0.00..2,457.89 rows=86,689 width=49) (actual rows= loops=)

66. 0.000 0.000 ↓ 0.0

Hash (cost=2.35..2.35 rows=7 width=4) (actual rows= loops=)

67. 0.000 0.000 ↓ 0.0

Seq Scan on exchangerate (cost=0.00..2.35 rows=7 width=4) (actual rows= loops=)

  • Filter: ((variablecurrencyid = $0) AND (('now'::cstring)::date >= effectivedate) AND (('now'::cstring)::date <= enddate))
68. 0.000 0.000 ↓ 0.0

Hash (cost=1.66..1.66 rows=66 width=16) (actual rows= loops=)

69. 0.000 0.000 ↓ 0.0

Seq Scan on clients cl (cost=0.00..1.66 rows=66 width=16) (actual rows= loops=)

70. 0.000 0.000 ↓ 0.0

Hash (cost=27.94..27.94 rows=994 width=39) (actual rows= loops=)

71. 0.000 0.000 ↓ 0.0

Seq Scan on userinfo ui (cost=0.00..27.94 rows=994 width=39) (actual rows= loops=)

72. 0.000 0.000 ↓ 0.0

Sort (cost=226,116.66..226,196.56 rows=31,960 width=60) (actual rows= loops=)

  • Sort Key: timeentrymetadata9.timeentryid
73. 0.000 0.000 ↓ 0.0

Seq Scan on timeentrymetadata timeentrymetadata9 (cost=0.00..223,725.42 rows=31,960 width=60) (actual rows= loops=)

  • Filter: (upper(key) = 'URN:REPLICON:TIME-ENTRY-METADATA-KEY:COMMENTS'::text)
74. 0.000 0.000 ↓ 0.0

Hash (cost=3,391.89..3,391.89 rows=86,689 width=63) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

Seq Scan on taskdenormalizedhierarchy tdh (cost=0.00..3,391.89 rows=86,689 width=63) (actual rows= loops=)

76. 0.000 0.000 ↓ 0.0

Hash (cost=85.76..85.76 rows=994 width=30) (actual rows= loops=)

77. 0.000 0.000 ↓ 0.0

Hash Join (cost=30.49..85.76 rows=994 width=30) (actual rows= loops=)

  • Hash Cond: (du.departmentid = dep.id)
78. 0.000 0.000 ↓ 0.0

Hash Join (cost=28.37..69.97 rows=994 width=20) (actual rows= loops=)

  • Hash Cond: (login.userid = du.userid)
79. 0.000 0.000 ↓ 0.0

Seq Scan on login (cost=0.00..27.94 rows=994 width=12) (actual rows= loops=)

80. 0.000 0.000 ↓ 0.0

Hash (cost=15.94..15.94 rows=994 width=8) (actual rows= loops=)

81. 0.000 0.000 ↓ 0.0

Seq Scan on departmentusers du (cost=0.00..15.94 rows=994 width=8) (actual rows= loops=)

82. 0.000 0.000 ↓ 0.0

Hash (cost=1.50..1.50 rows=50 width=18) (actual rows= loops=)

83. 0.000 0.000 ↓ 0.0

Seq Scan on departments dep (cost=0.00..1.50 rows=50 width=18) (actual rows= loops=)

84. 0.000 0.000 ↓ 0.0

Hash (cost=27.94..27.94 rows=994 width=18) (actual rows= loops=)

85. 0.000 0.000 ↓ 0.0

Seq Scan on userinfo userinfo10 (cost=0.00..27.94 rows=994 width=18) (actual rows= loops=)

86. 0.000 0.000 ↓ 0.0

Hash (cost=7.77..7.77 rows=377 width=41) (actual rows= loops=)

87. 0.000 0.000 ↓ 0.0

Seq Scan on billingrate billingrate11 (cost=0.00..7.77 rows=377 width=41) (actual rows= loops=)