我有這個簡單的SQL作爲一個SSIS任務的源:TSQL視圖選擇優化時,功能存在
Select * from budgetview
來源是:
CREATE VIEW [dbo].[BudgetView] AS
SELECT DISTINCT Country,
SDCO AS Company,
SDAN8 AS Customer,
SDLITM AS PrintableItemNumber,
dbo.fn_DateFromJulian(SDIVD) AS Date,
SDPQOR/100.0 AS Quantity,
SDAEXP/100.0 AS Value,
SDITWT/10000.0 AS Weight
FROM dbo.F553460
有索引的,每個NO意見事情似乎優化。
功能fn_DateFromJulian
來源:
CREATE FUNCTION [dbo].[fn_DateFromJulian]
(
@JulianDate numeric(6,0)
)
RETURNS date
AS
BEGIN
declare @resultdate date=dateadd(year,@JulianDate/1000,'1900-01-01')
set @resultdate=dateadd(day,@JulianDate%1000 -1,@resultdate)
return @resultdate
END
的問題是,我正在等待約20分鐘只是爲了獲得SSIS去行....
我等待20分鐘有開始之前
有沒有任何建議找到罪魁禍首?
標量是邪惡的 http://sqlblog.com/blogs/paul_white/archive/2012/09/05/compute-scalars-expressions-and-execution-plan-performance.aspx http://sqlblog.com /blogs/rob_farley/archive/2011/11/08/when-is-a-sql-function-not-a-function.aspx在我看來,理想的做法是將其轉換爲內聯表值函數,然後使用它是這樣的。可以爲你節省一些處理時間。另一件事你可以通過提示來加速第一個10k,但在這裏似乎有問題http://sqlblog.com/blogs/rob_farley/archive/2011/02/17/the-ssis-tuning-tip-that-everyone -misses.aspx – billinkc
你能幫我理解你的功能嗎?看看[wiki文章](http://en.wikipedia.org/wiki/Julian_day),我應該能夠通過2451545進入函數並獲得2001-01-1,但函數只接受6位數字 – billinkc
否它是這樣的:110235是2010年的第235天。我在我們的ERP中使用JDEdwards。看到這個:http://stackoverflow.com/questions/1171208/what-is-the-precise-definition-of-jdes-julian-date-format – e4rthdog