Advertisement
bytecoded

Most Costly Query by CPU (4)

Oct 29th, 2019
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 10.82 KB | None | 0 0
  1. (@P1 NUMERIC(10),@P2 NUMERIC(10),@P3 NUMERIC(10),@P4 datetime2(3),@P5 NUMERIC(10),@P6 NUMERIC(10),@P7 NUMERIC(10),@P8 datetime2(3),@P9 NUMERIC(10),@P10 NUMERIC(10),@P11 NUMERIC(10),@P12 datetime2(3),@P13 datetime2(3),@P14 NUMERIC(10),@P15 NUMERIC(10),@P16 NUMERIC(10),@P17 datetime2(3),@P18 NUMERIC(10),@P19 NUMERIC(10),@P20 NUMERIC(10),@P21 varbinary(16),@P22 NUMERIC(10),@P23 NUMERIC(10),@P24 varbinary(16),@P25 varbinary(16),@P26 NUMERIC(10),@P27 NUMERIC(10),@P28 NUMERIC(10),@P29 NUMERIC(10),@P30 NUMERIC(10),@P31 NUMERIC(10),@P32 NUMERIC(10),@P33 NUMERIC(10),@P34 NUMERIC(10),@P35 NUMERIC(10),@P36 NUMERIC(10),@P37 NUMERIC(10),@P38 NUMERIC(10),@P39 NUMERIC(10),@P40 NUMERIC(10),@P41 NUMERIC(10),@P42 NUMERIC(10),@P43 NUMERIC(10),@P44 NUMERIC(10),@P45 NUMERIC(10),@P46 NUMERIC(10),@P47 NUMERIC(10),@P48 NUMERIC(10),@P49 NUMERIC(10),@P50 NUMERIC(10),@P51 NUMERIC(10),@P52 NUMERIC(10),@P53 NUMERIC(10),@P54 NUMERIC(10),@P55 NUMERIC(10),@P56 varbinary(16),@P57 NUMERIC(10),@P58 NUMERIC(10),@P59 NUMERIC(10),@P60 NUMERIC(10),@P61 NUMERIC(10),@P62 NUMERIC(10),@P63 NUMERIC(10),@P64 NUMERIC(10),@P65 NUMERIC(10),@P66 NUMERIC(10),@P67 NUMERIC(10),@P68 NUMERIC(10),@P69 NUMERIC(10),@P70 NUMERIC(10),@P71 NUMERIC(10),@P72 NUMERIC(10),@P73 NUMERIC(10),@P74 NUMERIC(10),@P75 NUMERIC(10),@P76 NUMERIC(10),@P77 NUMERIC(10),@P78 NUMERIC(10),@P79 NUMERIC(10),@P80 NUMERIC(10),@P81 NUMERIC(10),@P82 NUMERIC(10),@P83 NUMERIC(10),@P84 NUMERIC(10),@P85 NUMERIC(10),@P86 NUMERIC(10),@P87 varbinary(16))SELECT TOP 25
  2. T1._IDRRef,
  3. T1._Marked,
  4. T1._Number,
  5. T1._Date_Time,
  6. T1._Posted,
  7. T1._Fld4621RRef,
  8. T1._Fld4622RRef,
  9. T1._Fld4625RRef,
  10. T1._Fld4633,
  11. T1._Fld4635RRef,
  12. T1._Fld4657RRef,
  13. CASE WHEN ((T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),0.0) > 0.0) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 4.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 6.0 ELSE 5.0 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 0.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 2.0 ELSE 1.0 END END ELSE 7.0 END,
  14. T11._Fld12313RRef,
  15. CASE WHEN ((ISNULL(CAST(T12.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) > 0.0) THEN (ISNULL(CAST(T12.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) ELSE 0.0 END,
  16. CASE WHEN (T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) THEN CASE WHEN T1._Posted = 0x01 THEN CASE WHEN T1._Fld14039 = 0x01 THEN CASE WHEN (ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) <= 0.0) THEN 0.0 WHEN ((CAST(ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) AS NUMERIC(26, 8)) / ISNULL(CAST(T14.Fld14035Receipt_ AS NUMERIC(21, 3)),0.0)) <= 0.5) THEN 1.0 WHEN ((CAST(ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) AS NUMERIC(26, 8)) / ISNULL(CAST(T14.Fld14035Receipt_ AS NUMERIC(21, 3)),0.0)) < 1.0) THEN 2.0 WHEN ((CAST(ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) AS NUMERIC(26, 8)) / ISNULL(CAST(T14.Fld14035Receipt_ AS NUMERIC(21, 3)),0.0)) >= 1.0) THEN 3.0 END ELSE 3.0 END ELSE 0.0 END ELSE 7.0 END,
  17. T16._Fld1191
  18. FROM dbo._Document233 T1
  19. LEFT OUTER JOIN (SELECT
  20. T3._Fld11328RRef AS Fld11328RRef,
  21. CAST(SUM(T3._Fld11330) AS NUMERIC(33, 8)) AS Fld11330Turnover_
  22. FROM dbo._AccumRgTn11332 T3
  23. WHERE ((T3._Fld595 = @P1)) AND ((T3._Fld11330 <> @P2))
  24. GROUP BY T3._Fld11328RRef
  25. HAVING (CAST(SUM(T3._Fld11330) AS NUMERIC(33, 8))) <> 0.0) T2
  26. ON (T1._IDRRef = T2.Fld11328RRef)
  27. LEFT OUTER JOIN (SELECT
  28. T5._Fld10540_TYPE AS Fld10540_TYPE,
  29. T5._Fld10540_RTRef AS Fld10540_RTRef,
  30. T5._Fld10540_RRRef AS Fld10540_RRRef,
  31. CAST(SUM(T5._Fld10545) AS NUMERIC(33, 8)) AS Fld10545Balance_
  32. FROM dbo._AccumRgT10549 T5
  33. WHERE ((T5._Fld595 = @P3)) AND (T5._Period = @P4 AND (T5._Fld10545 <> @P5) AND (T5._Fld10545 <> @P6))
  34. GROUP BY T5._Fld10540_TYPE,
  35. T5._Fld10540_RTRef,
  36. T5._Fld10540_RRRef
  37. HAVING (CAST(SUM(T5._Fld10545) AS NUMERIC(33, 8))) <> 0.0) T4
  38. ON (0x08 = T4.Fld10540_TYPE AND 0x000000E9 = T4.Fld10540_RTRef AND T1._IDRRef = T4.Fld10540_RRRef)
  39. LEFT OUTER JOIN (SELECT
  40. T7.Fld10344RRef AS Fld10344RRef,
  41. CAST(SUM(T7.Fld10346Balance_) AS NUMERIC(38, 8)) AS Fld10346Balance_
  42. FROM (SELECT
  43. T8._Fld10344RRef AS Fld10344RRef,
  44. CAST(SUM(T8._Fld10346) AS NUMERIC(33, 8)) AS Fld10346Balance_
  45. FROM dbo._AccumRgT10349 T8
  46. WHERE ((T8._Fld595 = @P7)) AND (T8._Period = @P8 AND (T8._Fld10346 <> @P9) AND (T8._Fld10346 <> @P10))
  47. GROUP BY T8._Fld10344RRef
  48. HAVING (CAST(SUM(T8._Fld10346) AS NUMERIC(33, 8))) <> 0.0
  49. UNION ALL SELECT
  50. T9._Fld10344RRef AS Fld10344RRef,
  51. CAST(CAST(SUM(CASE WHEN T9._RecordKind = 0.0 THEN -T9._Fld10346 ELSE T9._Fld10346 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld10346Balance_
  52. FROM dbo._AccumRg10339 T9
  53. WHERE ((T9._Fld595 = @P11)) AND (T9._Period >= @P12 AND T9._Period < @P13 AND T9._Active = 0x01)
  54. GROUP BY T9._Fld10344RRef
  55. HAVING (CAST(CAST(SUM(CASE WHEN T9._RecordKind = 0.0 THEN -T9._Fld10346 ELSE T9._Fld10346 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T7
  56. GROUP BY T7.Fld10344RRef
  57. HAVING (CAST(SUM(T7.Fld10346Balance_) AS NUMERIC(38, 8))) <> 0.0) T6
  58. ON (T1._IDRRef = T6.Fld10344RRef)
  59. LEFT OUTER JOIN dbo._InfoRg9134 T10
  60. ON ((0x08 = T10._Fld9136_TYPE AND 0x000000E9 = T10._Fld9136_RTRef AND T1._IDRRef = T10._Fld9136_RRRef)) AND (T10._Fld595 = @P14)
  61. LEFT OUTER JOIN dbo._InfoRg11720 T11
  62. ON ((0x08 = T11._Fld12312_TYPE AND 0x000000E9 = T11._Fld12312_RTRef AND T1._IDRRef = T11._Fld12312_RRRef)) AND (T11._Fld595 = @P15)
  63. LEFT OUTER JOIN (SELECT
  64. T13._Fld10332_TYPE AS Fld10332_TYPE,
  65. T13._Fld10332_RTRef AS Fld10332_RTRef,
  66. T13._Fld10332_RRRef AS Fld10332_RRRef,
  67. CAST(SUM(T13._Fld10335) AS NUMERIC(33, 8)) AS Fld10335Balance_
  68. FROM dbo._AccumRgT10337 T13
  69. WHERE ((T13._Fld595 = @P16)) AND (T13._Period = @P17 AND (T13._Fld10335 <> @P18) AND (T13._Fld10335 <> @P19))
  70. GROUP BY T13._Fld10332_TYPE,
  71. T13._Fld10332_RTRef,
  72. T13._Fld10332_RRRef
  73. HAVING (CAST(SUM(T13._Fld10335) AS NUMERIC(33, 8))) <> 0.0) T12
  74. ON (0x08 = T12.Fld10332_TYPE AND 0x000000E9 = T12.Fld10332_RTRef AND T1._IDRRef = T12.Fld10332_RRRef)
  75. LEFT OUTER JOIN (SELECT
  76. T15._Fld14033RRef AS Fld14033RRef,
  77. CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN T15._Fld14035 ELSE 0.0 END) AS NUMERIC(26, 8)) AS Fld14035Receipt_,
  78. CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN 0.0 ELSE T15._Fld14035 END) AS NUMERIC(26, 8)) AS Fld14035Expense_
  79. FROM dbo._AccumRg14026 T15
  80. WHERE ((T15._Fld595 = @P20)) AND (T15._Active = 0x01 AND ((T15._Fld14031RRef = @P21)))
  81. GROUP BY T15._Fld14033RRef
  82. HAVING (CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN T15._Fld14035 ELSE 0.0 END) AS NUMERIC(26, 8))) <> 0.0 OR (CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN 0.0 ELSE T15._Fld14035 END) AS NUMERIC(26, 8))) <> 0.0) T14
  83. ON (T14.Fld14033RRef = T1._IDRRef)
  84. LEFT OUTER JOIN dbo._Reference51 T16
  85. ON (T1._Fld4635RRef = T16._IDRRef) AND (T16._Fld595 = @P22)
  86. WHERE ((T1._Fld595 = @P23)) AND ((T1._Fld4621RRef = @P24) AND ((CASE WHEN ((T1._Fld4657RRef = @P25) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),@P26) > @P27) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P28) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P29)) THEN @P30 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P31) = @P32) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P33) > @P34)) THEN @P35 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P36) AS NUMERIC(33, 8)) / @P37) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P38)) THEN @P39 ELSE @P40 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P41) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P42)) THEN @P43 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P44) = @P45) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P46) > @P47)) THEN @P48 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P49) AS NUMERIC(33, 8)) / @P50) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P51)) THEN @P52 ELSE @P53 END END ELSE @P54 END > @P55) OR ((CASE WHEN ((T1._Fld4657RRef = @P56) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),@P57) > @P58) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P59) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P60)) THEN @P61 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P62) = @P63) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P64) > @P65)) THEN @P66 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P67) AS NUMERIC(33, 8)) / @P68) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P69)) THEN @P70 ELSE @P71 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P72) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P73)) THEN @P74 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P75) = @P76) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P77) > @P78)) THEN @P79 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P80) AS NUMERIC(33, 8)) / @P81) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P82)) THEN @P83 ELSE @P84 END END ELSE @P85 END = @P86) AND (T1._IDRRef >= @P87))))
  87. ORDER BY (CASE WHEN ((T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),0.0) > 0.0) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 4.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 6.0 ELSE 5.0 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 0.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 2.0 ELSE 1.0 END END ELSE 7.0 END), (T1._IDRRef)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement