Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Microsoft SQL Server Новый топик    Ответить
 Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
Здравствуйте.
Есть запрос
8 фев 13, 13:45    [13897276]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
_djХомяГ
Guest
@# это таблицы
при использовании # таблиц изменяется статистика , возможно происходит рекомпеляция
8 фев 13, 13:48    [13897320]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
Черт, случайно отправилось.
Итак, запрос
+
	;WITH Quotes AS
	(
		SELECT a.CandleDateTime, p.Symbol, a.AskHigh, a.AskLow, a.BidHigh, a.BidLow
		FROM
		(
			SELECT a.CandleDateTime, a.PairID, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.AskHigh END AS AskHigh, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.AskLow END AS AskLow, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.BidHigh END AS BidHigh, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.BidLow END AS BidLow
			FROM dbo.eConCandles1M AS a --WITH(NOLOCK, FORCESEEK) 
			UNION ALL
			SELECT af.CandleDateTime, af.PairID, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.AskHigh END AS AskHigh, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.AskLow END AS AskLow, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.BidHigh END AS BidHigh, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.BidLow END AS BidLow
			FROM dbo.eConQuotesFlat1M AS af --WITH(NOLOCK, FORCESEEK)
		) as a		
		INNER JOIN dbo.eConPairs AS p WITH (NOLOCK)
			ON a.PairID = p.PairID
	), Equities AS
	--------------------------------------------------------------------------------------
	(	
		-- Calculate equity low/high per each ticket ------------------------------------------
		SELECT st.StatsAccountID, st.StartDate, st.EndDate,
			ISNULL(SUM(ISNULL(CASE 
				WHEN st.CurrentDay = @Today THEN NULL
				WHEN st.IsSell = 1 THEN (st.OpenPrice - ((q.AskHigh + q.AskLow) / 2)) * st.Units 
					* CASE WHEN st.IsCurrency = 1 THEN 1 ELSE ISNULL(((q1.AskHigh + q1.AskLow) / 2), 1/((q2.AskHigh + q2.AskLow) / 2)) END 
				WHEN st.IsBuy = 1 THEN (((q.BidHigh + q.BidLow) / 2) - st.OpenPrice) * st.Units
					* CASE WHEN st.IsCurrency = 1 THEN 1 ELSE ISNULL(((q1.BidHigh + q1.BidLow) / 2), 1/((q2.BidHigh + q2.BidLow) / 2)) END 
			END, st.Profit)), 0.0) AS Profit
		FROM
		(
			SELECT r.StartDate, r.EndDate, t.OpenPrice, t.Units, t.Profit, CAST(r.EndDate AS DATE) AS CurrentDay,
				t.Item, (RIGHT(t.Item, 3) + t.Currency) AS Item1, (t.Currency + RIGHT(t.Item, 3)) AS Item2,
				CASE WHEN t.[Type] LIKE 'sell%' THEN 1 ELSE 0 END AS IsSell, CASE WHEN t.[Type] LIKE 'buy%' THEN 1 ELSE 0 END AS IsBuy,
				CASE WHEN (RIGHT(t.Item, 3) = t.Currency) THEN 1 ELSE 0 END AS IsCurrency 	, r.StatsAccountID					
			FROM @Ranges AS r
			LEFT JOIN 
			(
				SELECT t.StatsTicketsId, t.Currency, t.Item, ISNULL(e.Equity, t.Profit) AS Profit,
					t.OpenPrice, t.Units, t.OpenTimeUtc, t.CloseTimeUtc, t.[Type], t.StatsAccountID
				FROM #TicketsTWR AS t
	            join #Account a on a.StatsAccountID = t.StatsAccountID
				LEFT JOIN dbo.STS_StatsTicketsEquity AS e
					ON t.StatsTicketsId = e.StatsTicketsId AND CAST(DATEADD(SECOND, -1, e.TicketTime) AS DATE) = CAST(a.DateEnd AS DATE)
				WHERE t.[Type] NOT IN ('balance', 'credit')
			)AS t
				ON ((t.OpenTimeUtc BETWEEN r.StartDate AND r.EndDate AND (t.CloseTimeUtc > r.EndDate OR t.CloseTimeUtc IS NULL))
					OR (t.OpenTimeUtc < r.StartDate AND (t.CloseTimeUtc > r.EndDate OR t.CloseTimeUtc IS NULL)))
					and r.StatsAccountID = t.StatsAccountID
		) AS st
		LEFT JOIN Quotes as q
			ON q.Symbol = st.Item AND q.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q1
			ON q1.Symbol = st.Item1 AND q1.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q2
			ON q2.Symbol = st.Item2 AND q2.CandleDateTime = st.EndDate
		GROUP BY st.StartDate, st.EndDate	, st.StatsAccountID		
	---------------------------------------------------------------------------------------------------
	)
		
	INSERT INTO @Equities (StatsAccountID, StartDate, EndDate, Profit, RowNum)
	SELECT r.StatsAccountID, r.StartDate, r.EndDate, r.Profit, ROW_NUMBER() OVER (partition by r.StatsAccountID ORDER BY r.StartDate, r.EndDate)
	FROM Equities AS r

Выполняется быстро, план в аттаче.
Из хулиганских побуждений меняем табличную переменную @Ranges на временную таблицу. Стоимость плана увеличивается в 120(!!!) раз, время выполнения тоже увеличивается. С чем может быть связано такое изменение?

К сообщению приложен файл (планы .7z - 18Kb) cкачать
8 фев 13, 13:49    [13897331]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
_djХомяГ
при использовании # таблиц изменяется статистика

Если верить документации, для временной таблицы сервер создает статистику, а для табличной переменной - нет. Но из плана видно, что в случае табличной переменной сервер куда точнее угадывает количество строк в результате Hash Match (ID 12 для запроса с времянкой, 13 для запроса с переменной). Опять-таки не понятно, почему.
8 фев 13, 13:58    [13897453]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
tpg
Member

Откуда: Novosibirsk
Сообщений: 23902
Вы б весь код показали, а не понравившейся кусок. А так - годание на кофейной гуще...
(ещё поди в процедуре все это)
8 фев 13, 14:11    [13897617]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Дедушка
Member

Откуда: Город трёх революций
Сообщений: 5114
и планы в текстовом виде сюда (а то качай какие то архивы)
8 фев 13, 15:49    [13898556]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Мистер Хенки
Member

Откуда: канализация
Сообщений: 6615
почему то
в
LEFT JOIN Quotes as q
			ON q.Symbol = st.Item AND q.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q1
			ON q1.Symbol = st.Item1 AND q1.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q2
			ON q2.Symbol = st.Item2 AND q2.CandleDateTime = st.EndDate

В обоих планах как то очень разное количество записей джойнится, хотя вроде порядо соединения таблиц похож очень, только тип соединения разный. Есть такое ощущение, что на разных данных выполнили разные запросы, а потом сравнивают их скорость выполнения
8 фев 13, 16:13    [13898755]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
+ Весь код до понравившегося куска + 2 варианта понравившегося куска: с временной таблицей и табличной переменной последовательно (кроме этого еще тестировал и реплэйся, результат не меняется). Выдрано из процедуры :)
	SET NOCOUNT ON;
	
	declare @Today DATETIME = CAST(GETUTCDATE() AS DATE)
   --select @xml aaa into qwe
	SELECT StatsAccountID,
		DateStart,
		DateEnd,
		DateStartTWR,
		DateStartLoc = dateadd(day, 0, datediff(day, 0, DateStart)),
		DateEndLoc = dateadd(day, 0, datediff(day, 0, DateEnd)),
		DateStartLocTWR = dateadd(day, 0, datediff(day, 0, DateStartTWR)),
		OpenTimeStartLoc = null,
		OpenTimeEndLoc = null,
		CloseTimeStartLoc = null,
		CloseTimeEndLoc = null	 
	INTO #Account
	FROM ( 
		SELECT t.c.value('./@StatsAccountID', 'int') StatsAccountID ,
			t.c.value('./@DateStart', 'datetime') DateStart ,
			t.c.value('./@DateEnd', 'datetime') DateEnd ,
			t.c.value('./@DateStartTWR', 'datetime') DateStartTWR 
	
		FROM @xml.nodes('/root/Account') t(c)
		)  a
	 
--	---------------------------------------------------------------------
  
	CREATE TABLE #Tickets (StatsAccountID int, DateValue DATE, Profit DECIMAL(18, 5), StatsTicketsId INT, [Type] NVARCHAR(50),
							Currency NVARCHAR(10), OpenPrice DECIMAL(18, 5), Units  DECIMAL(18, 5), OpenTimeUtc DATETIME, CloseTimeUtc DATETIME,
							Item NVARCHAR(50), OrderStatus NVARCHAR(30), CloseTimeBalance DECIMAL(18, 5), Balance DECIMAL(18, 5), RowNum INT)

--	---- Applay filters to tickets list-------------------------------------------------------
	SELECT a.StatsAccountID, sb.StartBalance, ib.InitialBalance, ic.InitalCredit, Deposit = ib.InitialBalance + ic.InitalCredit
	INTO #StartBalanceDeposit
	FROM #Account a
	CROSS APPLY	
	(
		SELECT StartBalance = ISNULL(SUM(ISNULL(t.Profit, 0.0) + ISNULL(t.Swap, 0.0) + ISNULL(t.Commission, 0.0)) , 0.0) 
		FROM dbo.STS_StatsTickets AS t
		WHERE a.StatsAccountID = t.StatsAccountId AND t.isCanceled = 0 
			AND ((t.CloseTimeUtc <= a.DateStartLoc AND t.[Type] NOT IN ('balance', 'credit')) 
			OR (t.OpenTimeUtc <= a.DateStartLoc AND t.[Type] IN ('balance', 'credit')))

	) as sb
	OUTER APPLY	
	(
		SELECT InitialBalance = ISNULL(SUM((ISNULL(st.Profit, 0.0) + ISNULL(st.Swap, 0.0) + ISNULL(st.Commission, 0.0))), 0.0) 
		FROM dbo.STS_StatsTickets AS st 
		WHERE st.StatsAccountId = a.StatsAccountId AND st.isCanceled = 0 AND st.[Type] = 'balance' AND st.OpenTimeUtc <= a.DateStartLoc
	) as ib
	
	OUTER APPLY	
	(
		SELECT InitalCredit = ISNULL(SUM((ISNULL(st.Profit, 0.0) + ISNULL(st.Swap, 0.0) + ISNULL(st.Commission, 0.0))), 0.0)
		FROM dbo.STS_StatsTickets AS st
		WHERE st.StatsAccountId = a.StatsAccountId AND st.isCanceled = 0 
			AND st.[Type] = 'credit' AND st.OpenTimeUtc <= a.DateStartLoc
		) ic
	WHERE sb.StartBalance <> 0 
	  
	INSERT INTO #Tickets (StatsAccountID, DateValue, Profit, StatsTicketsId, [Type], Currency, OpenPrice, Units, OpenTimeUtc, CloseTimeUtc, Item, OrderStatus, CloseTimeBalance, Balance, RowNum)
	SELECT a.StatsAccountID, CAST(a.DateStartLoc as date), sbd.InitialBalance, -1, 'balance', 'USD', NULL, NULL, a.DateStartLoc, NULL, NULL, 'CLOSED', 0.0, sbd.StartBalance, 1 
	FROM #Account a 
	JOIN #StartBalanceDeposit sbd on sbd.StatsAccountID = a.StatsAccountID
	WHERE sbd.InitialBalance <> 0
	UNION ALL
	SELECT a.StatsAccountID, CAST(a.DateStartLoc as date), sbd.InitalCredit, -2, 'credit', 'USD', NULL, NULL, a.DateStartLoc, NULL, NULL, 'CLOSED', 0.0, sbd.StartBalance, 2
	FROM #Account a 
	JOIN #StartBalanceDeposit sbd on sbd.StatsAccountID = a.StatsAccountID
	WHERE sbd.InitalCredit <> 0
	UNION ALL
	SELECT a.StatsAccountID, CAST(a.DateStartLoc as date), sbd.StartBalance - sbd.Deposit, 0, 'sell', 'USD', NULL, 1, a.DateStartLoc, a.DateStartLoc, 'EURUSD', 'CLOSED', sbd.StartBalance, sbd.Deposit, 3
	FROM #Account a 
	JOIN #StartBalanceDeposit sbd on sbd.StatsAccountID = a.StatsAccountID
	WHERE sbd.StartBalance - sbd.Deposit <> 0
     

	INSERT INTO #Tickets (StatsAccountID, DateValue, Profit, StatsTicketsId, [Type], Currency,
			OpenPrice, Units, OpenTimeUtc, CloseTimeUtc, Item, OrderStatus, CloseTimeBalance, Balance, RowNum)
	SELECT a.StatsAccountID, CAST(ISNULL(ts.CloseTimeUtc, CASE WHEN (ts.[Type] NOT IN ('balance', 'credit') AND ts.OpenTimeUtc < a.DateStartLoc) THEN a.DateStart ELSE ts.OpenTimeUtc END) as date) AS DateValue, 			
		SUM(ISNULL(ts.Profit, 0.0) + ISNULL(ts.Swap, 0.0) + ISNULL(ts.Commission, 0.0)) AS Profit,
		MAX(ts.StatsTicketsId) AS StatsTicketsId, ts.[Type], ISNULL(sa.Currency, 'USD') AS Currency, ts.OpenPrice, ts.Size * ISNULL(ts.Units, 100000) AS Units,
		DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  CASE WHEN (ts.[Type] NOT IN ('balance', 'credit') AND ts.OpenTimeUtc < a.DateStartLoc) THEN a.DateStart ELSE ts.OpenTimeUtc END), 0) AS OpenTimeUtc, 
		DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  ts.CloseTimeUtc), 0), ISNULL(i.Symbol, ts.Item), ts.OrderStatus, ts.CloseTimeBalance, 
		ts.Balance, ROW_NUMBER() OVER (partition by a.StatsAccountID ORDER BY ts.OpenTimeUtc) + (select coalesce(max(RowNum), 0) from #Tickets) AS RowNum
	 
	FROM #Account a
	join dbo.STS_StatsTickets ts on ts.StatsAccountID = a.StatsAccountID AND ts.isCanceled = 0
    JOIN dbo.STS_StatsAccounts AS sa ON sa.StatsAccountId = ts.StatsAccountId 
	LEFT JOIN
	(
		SELECT p.Symbol, pa.Alias 
		FROM dbo.eConPairs AS p
		INNER JOIN eConPairAliases AS pa
			ON pa.PairID = p.PairID 
	) AS i
		ON ts.Item = i.Alias
	WHERE ts.OrderStatus IN ('OPENED','CLOSED') 
		AND ((ts.OpenTimeUtc BETWEEN a.DateStartLoc AND a.DateEnd) OR (ts.[Type] NOT IN ('balance', 'credit') AND ISNULL(ts.CloseTimeUtc, GETDATE()) BETWEEN a.DateStartLoc AND a.DateEnd)
			OR (ts.OpenTimeUtc < a.DateStartLoc AND (ts.CloseTimeUtc > a.DateEnd OR (ts.CloseTimeUtc IS NULL AND ts.[Type] NOT IN ('balance', 'credit')))))

 	GROUP BY a.StatsAccountID, CAST(ISNULL(ts.CloseTimeUtc, CASE WHEN (ts.[Type] NOT IN ('balance', 'credit') AND ts.OpenTimeUtc < a.DateStartLoc) THEN a.DateStart ELSE ts.OpenTimeUtc END) as date),
		ts.[Type], ISNULL(sa.Currency, 'USD'), ts.OpenPrice, ts.Size * ISNULL(ts.Units, 100000),
		DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  CASE WHEN (ts.[Type] NOT IN ('balance', 'credit') AND ts.OpenTimeUtc < a.DateStartLoc) THEN a.DateStart ELSE ts.OpenTimeUtc END), 0),
		DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  ts.CloseTimeUtc), 0), ISNULL(i.Symbol, ts.Item), ts.OrderStatus, ts.CloseTimeBalance, ts.Balance, ts.OpenTimeUtc

	CREATE NONCLUSTERED INDEX idx_CloseTimeUtc ON #Tickets (CloseTimeUtc) 
--	--------------------------------------------------------------------------------------------
	
--	------- Tickets for TWR ----------------------------------------------
	CREATE TABLE #TicketsTWR (StatsAccountID int, Profit DECIMAL(18, 5), StatsTicketsId INT, [Type] NVARCHAR(50), Currency NVARCHAR(10), OpenPrice DECIMAL(18, 5), Units DECIMAL(18, 5), 
								OpenTimeUtc DATETIME, CloseTimeUtc DATETIME, Item NVARCHAR(50), RowNum INT)
		
  
	SELECT a.StatsAccountID, sb.StartBalance, ib.InitialBalance, ic.InitalCredit, Deposit = ib.InitialBalance + ic.InitalCredit
	INTO #StartBalanceDepositTWR
	FROM #Account a
	CROSS APPLY	
	(
		SELECT StartBalance = ISNULL(SUM(ISNULL(t.Profit, 0.0) + ISNULL(t.Swap, 0.0) + ISNULL(t.Commission, 0.0)) , 0.0) 
		FROM dbo.STS_StatsTickets AS t
		WHERE a.StatsAccountID = t.StatsAccountId AND t.isCanceled = 0 
			AND ((t.CloseTimeUtc <= a.DateStartLocTWR AND t.[Type] NOT IN ('balance', 'credit')) 
			OR (t.OpenTimeUtc <= a.DateStartLocTWR AND t.[Type] IN ('balance', 'credit')))

	) as sb
	OUTER APPLY	
	(
		SELECT InitialBalance = ISNULL(SUM((ISNULL(st.Profit, 0.0) + ISNULL(st.Swap, 0.0) + ISNULL(st.Commission, 0.0))), 0.0) 
		FROM dbo.STS_StatsTickets AS st 
		WHERE st.StatsAccountId = a.StatsAccountId AND st.isCanceled = 0 AND st.[Type] = 'balance' AND st.OpenTimeUtc <= a.DateStartLocTWR
	) as ib
	
	OUTER APPLY	
	(
		SELECT InitalCredit = ISNULL(SUM((ISNULL(st.Profit, 0.0) + ISNULL(st.Swap, 0.0) + ISNULL(st.Commission, 0.0))), 0.0)
		FROM dbo.STS_StatsTickets AS st
		WHERE st.StatsAccountId = a.StatsAccountId AND st.isCanceled = 0 
			AND st.[Type] = 'credit' AND st.OpenTimeUtc <= a.DateStartLocTWR
		) ic
	WHERE sb.StartBalance <> 0 
	AND a.DateStartLoc <> a.DateStartLocTWR
    
	INSERT INTO #TicketsTwr (Profit, StatsTicketsId, [Type], Currency, OpenPrice, Units, OpenTimeUtc, CloseTimeUtc, Item, RowNum)
	SELECT sbd.InitialBalance, -1, 'balance', 'USD', NULL, NULL, a.DateStartLocTWR, NULL, NULL, 1 
	FROM #Account a 
	JOIN #StartBalanceDepositTWR sbd on sbd.StatsAccountID = a.StatsAccountID
	WHERE sbd.InitialBalance <> 0
	UNION ALL
	SELECT sbd.InitalCredit, -2, 'credit', 'USD', NULL, NULL, a.DateStartLocTWR, NULL, NULL, 2
	FROM #Account a 
	JOIN #StartBalanceDepositTWR sbd on sbd.StatsAccountID = a.StatsAccountID
	WHERE sbd.InitalCredit <> 0
	UNION ALL
	SELECT sbd.StartBalance - sbd.Deposit, 0, 'sell', 'USD', NULL, 1, a.DateStartLocTWR, a.DateStartLocTWR, 'EURUSD', 3 	
	FROM #Account a 
	JOIN #StartBalanceDepositTWR sbd on sbd.StatsAccountID = a.StatsAccountID
	WHERE sbd.StartBalance - sbd.Deposit <> 0
 
	INSERT INTO #TicketsTWR (StatsAccountID, Profit, StatsTicketsId, [Type], Currency, OpenPrice, Units, OpenTimeUtc, CloseTimeUtc, Item, RowNum)
	SELECT a.StatsAccountID, SUM(ISNULL(ts.Profit, 0.0) + ISNULL(ts.Swap, 0.0) + ISNULL(ts.Commission, 0.0)) AS Profit,
		MAX(ts.StatsTicketsId) AS StatsTicketsId, ts.[Type], ISNULL(sa.Currency, 'USD') AS Currency, ts.OpenPrice, ts.Size * ISNULL(ts.Units, 100000) AS Units,
		DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  CASE WHEN (ts.[Type] NOT IN ('balance', 'credit') AND ts.OpenTimeUtc < a.DateStartLocTWR) THEN a.DateStartTWR ELSE ts.OpenTimeUtc END), 0) AS OpenTimeUtc, 
		DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  ts.CloseTimeUtc), 0), ISNULL(i.Symbol, ts.Item), ROW_NUMBER() OVER (partition by a.StatsAccountID ORDER BY ts.OpenTimeUtc) + (select coalesce(max(RowNum), 0) from #TicketsTWR) AS RowNum

	FROM #Account a
	join dbo.STS_StatsTickets ts on ts.StatsAccountID = a.StatsAccountID 
	INNER JOIN dbo.STS_StatsAccounts AS sa
	ON sa.StatsAccountId = ts.StatsAccountId
	LEFT JOIN
	(
		SELECT p.Symbol, pa.Alias 
		FROM dbo.eConPairs AS p
		INNER JOIN eConPairAliases AS pa
			ON pa.PairID = p.PairID 
	) AS i
	ON ts.Item = i.Alias 
	WHERE ts.OrderStatus IN ('OPENED','CLOSED') 
		AND ((ts.OpenTimeUtc BETWEEN a.DateStartLocTWR AND a.DateEnd) OR (ts.[Type] NOT IN ('balance', 'credit') AND ISNULL(ts.CloseTimeUtc, GETDATE()) BETWEEN a.DateStartLocTWR AND a.DateEnd)
			OR (ts.OpenTimeUtc < a.DateStartLocTWR AND (ts.CloseTimeUtc > a.DateEnd OR (ts.CloseTimeUtc IS NULL AND ts.[Type] NOT IN ('balance', 'credit'))))) 
			AND a.DateStartLoc <> a.DateStartLocTWR AND ts.isCanceled = 0

	GROUP BY a.StatsAccountID, ts.[Type], ISNULL(sa.Currency, 'USD'), ts.OpenPrice, ts.Size * ISNULL(ts.Units, 100000),
	DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  CASE WHEN (ts.[Type] NOT IN ('balance', 'credit') AND ts.OpenTimeUtc < a.DateStartLocTWR) THEN a.DateStartTWR ELSE ts.OpenTimeUtc END), 0),
	DATEADD(MINUTE, DATEDIFF(MINUTE, 0,  ts.CloseTimeUtc), 0), ISNULL(i.Symbol, ts.Item), ts.OpenTimeUtc
 
	INSERT INTO #TicketsTWR (StatsAccountID, Profit, StatsTicketsId, [Type], Currency, OpenPrice, Units, OpenTimeUtc, CloseTimeUtc, Item, RowNum)
	SELECT a.StatsAccountID, Profit, StatsTicketsId, [Type], Currency, OpenPrice, Units, OpenTimeUtc, CloseTimeUtc, Item, RowNum
	FROM #Tickets t
	join #Account a on a.StatsAccountID = t.StatsAccountID
	WHERE a.DateStartLoc = a.DateStartLocTWR 
 
--	----------------------------------------------------------------------

--	-- Forms of the balances ----------------------------
	DECLARE @Balance TABLE (StatsAccountID int, DateValue DATETIME, RowNum INT)
	INSERT INTO @Balance (StatsAccountID, DateValue, RowNum)
	SELECT StatsAccountID, DATEADD(SECOND, -DATEPART(SECOND, t.OpenTimeUtc), DATEADD(MILLISECOND, -DATEPART(MILLISECOND, t.OpenTimeUtc), t.OpenTimeUtc)),
		ROW_NUMBER() OVER (partition by t.StatsAccountID ORDER BY t.RowNum) 
	FROM #TicketsTWR AS t
	WHERE t.[Type] IN ('balance', 'credit')
--	--------------------------------------------------------------

--	-- Forms of the ranges -------------------------------------------
	DECLARE @Ranges TABLE (StatsAccountID int, StartDate DATETIME, EndDate DATETIME, UNIQUE CLUSTERED (StatsAccountID, StartDate, EndDate))
	INSERT INTO @Ranges (StatsAccountID, StartDate, EndDate)
	SELECT b1.StatsAccountID, b1.DateValue AS StartDate, ISNULL(b2.DateValue, a.DateEnd) AS EndDate 
	FROM @Balance AS b1
	join #Account a on a.StatsAccountID = b1.StatsAccountID
	LEFT JOIN @Balance AS b2
		ON b1.RowNum = b2.RowNum - 1
		AND b1.StatsAccountID = b2.StatsAccountID
 
--	---------------------------------------------------------------------

--	-- Determine balance on ranges ----------------------------------------
	DECLARE @Equities TABLE (StatsAccountID int, StartDate DATETIME, EndDate DATETIME, Profit DECIMAL(18, 5), RowNum INT)
	
	
--	----- 1M quotes + curent day------------------------------------------------
	;WITH Quotes AS
	(
		SELECT a.CandleDateTime, p.Symbol, a.AskHigh, a.AskLow, a.BidHigh, a.BidLow
		FROM
		(
			SELECT a.CandleDateTime, a.PairID, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.AskHigh END AS AskHigh, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.AskLow END AS AskLow, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.BidHigh END AS BidHigh, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.BidLow END AS BidLow
			FROM dbo.eConCandles1M AS a --WITH(NOLOCK, FORCESEEK) 
			UNION ALL
			SELECT af.CandleDateTime, af.PairID, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.AskHigh END AS AskHigh, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.AskLow END AS AskLow, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.BidHigh END AS BidHigh, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.BidLow END AS BidLow
			FROM dbo.eConQuotesFlat1M AS af --WITH(NOLOCK, FORCESEEK)
		) as a		
		INNER JOIN dbo.eConPairs AS p WITH (NOLOCK)
			ON a.PairID = p.PairID
	), Equities AS
	--------------------------------------------------------------------------------------
	(	
		-- Calculate equity low/high per each ticket ------------------------------------------
		SELECT st.StatsAccountID, st.StartDate, st.EndDate,
			ISNULL(SUM(ISNULL(CASE 
				WHEN st.CurrentDay = @Today THEN NULL
				WHEN st.IsSell = 1 THEN (st.OpenPrice - ((q.AskHigh + q.AskLow) / 2)) * st.Units 
					* CASE WHEN st.IsCurrency = 1 THEN 1 ELSE ISNULL(((q1.AskHigh + q1.AskLow) / 2), 1/((q2.AskHigh + q2.AskLow) / 2)) END 
				WHEN st.IsBuy = 1 THEN (((q.BidHigh + q.BidLow) / 2) - st.OpenPrice) * st.Units
					* CASE WHEN st.IsCurrency = 1 THEN 1 ELSE ISNULL(((q1.BidHigh + q1.BidLow) / 2), 1/((q2.BidHigh + q2.BidLow) / 2)) END 
			END, st.Profit)), 0.0) AS Profit
		FROM
		(
			SELECT r.StartDate, r.EndDate, t.OpenPrice, t.Units, t.Profit, CAST(r.EndDate AS DATE) AS CurrentDay,
				t.Item, (RIGHT(t.Item, 3) + t.Currency) AS Item1, (t.Currency + RIGHT(t.Item, 3)) AS Item2,
				CASE WHEN t.[Type] LIKE 'sell%' THEN 1 ELSE 0 END AS IsSell, CASE WHEN t.[Type] LIKE 'buy%' THEN 1 ELSE 0 END AS IsBuy,
				CASE WHEN (RIGHT(t.Item, 3) = t.Currency) THEN 1 ELSE 0 END AS IsCurrency 	, r.StatsAccountID					
			FROM @Ranges AS r
			LEFT JOIN 
			(
				SELECT t.StatsTicketsId, t.Currency, t.Item, ISNULL(e.Equity, t.Profit) AS Profit,
					t.OpenPrice, t.Units, t.OpenTimeUtc, t.CloseTimeUtc, t.[Type], t.StatsAccountID
				FROM #TicketsTWR AS t
	            join #Account a on a.StatsAccountID = t.StatsAccountID
				LEFT JOIN dbo.STS_StatsTicketsEquity AS e
					ON t.StatsTicketsId = e.StatsTicketsId AND CAST(DATEADD(SECOND, -1, e.TicketTime) AS DATE) = CAST(a.DateEnd AS DATE)
				WHERE t.[Type] NOT IN ('balance', 'credit')
			)AS t
				ON ((t.OpenTimeUtc BETWEEN r.StartDate AND r.EndDate AND (t.CloseTimeUtc > r.EndDate OR t.CloseTimeUtc IS NULL))
					OR (t.OpenTimeUtc < r.StartDate AND (t.CloseTimeUtc > r.EndDate OR t.CloseTimeUtc IS NULL)))
					and r.StatsAccountID = t.StatsAccountID
		) AS st
		LEFT JOIN Quotes as q
			ON q.Symbol = st.Item AND q.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q1
			ON q1.Symbol = st.Item1 AND q1.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q2
			ON q2.Symbol = st.Item2 AND q2.CandleDateTime = st.EndDate
		GROUP BY st.StartDate, st.EndDate	, st.StatsAccountID		
	---------------------------------------------------------------------------------------------------
	)
		
	INSERT INTO @Equities (StatsAccountID, StartDate, EndDate, Profit, RowNum)
	SELECT r.StatsAccountID, r.StartDate, r.EndDate, r.Profit, ROW_NUMBER() OVER (partition by r.StatsAccountID ORDER BY r.StartDate, r.EndDate)
	FROM Equities AS r

	OPTION (MAXRECURSION 0);
	
	select * into #Ranges from @Ranges
	create unique clustered index UQ_123 on #Ranges(StatsAccountID, StartDate, EndDate) 

	;WITH Quotes AS
	(
		SELECT a.CandleDateTime, p.Symbol, a.AskHigh, a.AskLow, a.BidHigh, a.BidLow
		FROM
		(
			SELECT a.CandleDateTime, a.PairID, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.AskHigh END AS AskHigh, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.AskLow END AS AskLow, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.BidHigh END AS BidHigh, 
				CASE WHEN a.BrokerServerID IS NULL THEN (a.AskClose + a.BidClose) / 2 ELSE a.BidLow END AS BidLow
			FROM dbo.eConCandles1M AS a --WITH(NOLOCK, FORCESEEK) 
			UNION ALL
			SELECT af.CandleDateTime, af.PairID, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.AskHigh END AS AskHigh, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.AskLow END AS AskLow, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.BidHigh END AS BidHigh, 
				CASE WHEN af.BrokerServerID IS NULL THEN (af.AskClose + af.BidClose) / 2 ELSE af.BidLow END AS BidLow
			FROM dbo.eConQuotesFlat1M AS af --WITH(NOLOCK, FORCESEEK)
		) as a		
		INNER JOIN dbo.eConPairs AS p WITH (NOLOCK)
			ON a.PairID = p.PairID
	), Equities AS
	--------------------------------------------------------------------------------------
	(	
		-- Calculate equity low/high per each ticket ------------------------------------------
		SELECT st.StatsAccountID, st.StartDate, st.EndDate,
			ISNULL(SUM(ISNULL(CASE 
				WHEN st.CurrentDay = @Today THEN NULL
				WHEN st.IsSell = 1 THEN (st.OpenPrice - ((q.AskHigh + q.AskLow) / 2)) * st.Units 
					* CASE WHEN st.IsCurrency = 1 THEN 1 ELSE ISNULL(((q1.AskHigh + q1.AskLow) / 2), 1/((q2.AskHigh + q2.AskLow) / 2)) END 
				WHEN st.IsBuy = 1 THEN (((q.BidHigh + q.BidLow) / 2) - st.OpenPrice) * st.Units
					* CASE WHEN st.IsCurrency = 1 THEN 1 ELSE ISNULL(((q1.BidHigh + q1.BidLow) / 2), 1/((q2.BidHigh + q2.BidLow) / 2)) END 
			END, st.Profit)), 0.0) AS Profit
		FROM
		(
			SELECT r.StartDate, r.EndDate, t.OpenPrice, t.Units, t.Profit, CAST(r.EndDate AS DATE) AS CurrentDay,
				t.Item, (RIGHT(t.Item, 3) + t.Currency) AS Item1, (t.Currency + RIGHT(t.Item, 3)) AS Item2,
				CASE WHEN t.[Type] LIKE 'sell%' THEN 1 ELSE 0 END AS IsSell, CASE WHEN t.[Type] LIKE 'buy%' THEN 1 ELSE 0 END AS IsBuy,
				CASE WHEN (RIGHT(t.Item, 3) = t.Currency) THEN 1 ELSE 0 END AS IsCurrency 	, r.StatsAccountID					
			FROM #Ranges AS r
			LEFT JOIN 
			(
				SELECT t.StatsTicketsId, t.Currency, t.Item, ISNULL(e.Equity, t.Profit) AS Profit,
					t.OpenPrice, t.Units, t.OpenTimeUtc, t.CloseTimeUtc, t.[Type], t.StatsAccountID
				FROM #TicketsTWR AS t
	            join #Account a on a.StatsAccountID = t.StatsAccountID
				LEFT JOIN dbo.STS_StatsTicketsEquity AS e
					ON t.StatsTicketsId = e.StatsTicketsId AND CAST(DATEADD(SECOND, -1, e.TicketTime) AS DATE) = CAST(a.DateEnd AS DATE)
				WHERE t.[Type] NOT IN ('balance', 'credit')
			)AS t
				ON ((t.OpenTimeUtc BETWEEN r.StartDate AND r.EndDate AND (t.CloseTimeUtc > r.EndDate OR t.CloseTimeUtc IS NULL))
					OR (t.OpenTimeUtc < r.StartDate AND (t.CloseTimeUtc > r.EndDate OR t.CloseTimeUtc IS NULL)))
					and r.StatsAccountID = t.StatsAccountID
		) AS st
		LEFT JOIN Quotes as q
			ON q.Symbol = st.Item AND q.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q1
			ON q1.Symbol = st.Item1 AND q1.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q2
			ON q2.Symbol = st.Item2 AND q2.CandleDateTime = st.EndDate
		GROUP BY st.StartDate, st.EndDate	, st.StatsAccountID		
	---------------------------------------------------------------------------------------------------
	)
		
	INSERT INTO @Equities (StatsAccountID, StartDate, EndDate, Profit, RowNum)
	SELECT r.StatsAccountID, r.StartDate, r.EndDate, r.Profit, ROW_NUMBER() OVER (partition by r.StatsAccountID ORDER BY r.StartDate, r.EndDate)
	FROM Equities AS r

	OPTION (MAXRECURSION 0);
	return

Планы в текстовом виде:
+ Табличная переменная

1055	1	  |--Table Insert(OBJECT:(@Equities), SET:([StatsAccountID] = @Ranges.[StatsAccountID] as [r].[StatsAccountID],[StartDate] = @Ranges.[StartDate] as [r].[StartDate],[EndDate] = @Ranges.[EndDate] as [r].[EndDate],[Profit] = [Expr1113],[RowNum] = [Expr1114]))	12	2	1	Table Insert	Insert	OBJECT:(@Equities), SET:([StatsAccountID] = @Ranges.[StatsAccountID] as [r].[StatsAccountID],[StartDate] = @Ranges.[StartDate] as [r].[StartDate],[EndDate] = @Ranges.[EndDate] as [r].[EndDate],[Profit] = [Expr1113],[RowNum] = [Expr1114])	NULL	1102,802	0,03962685	0,001102802	9	6,130473	NULL	NULL	PLAN_ROW	0	1
0	0	       |--Compute Scalar(DEFINE:([Expr1113]=CONVERT_IMPLICIT(decimal(18,5),[Expr1111],0), [Expr1114]=CONVERT_IMPLICIT(int,[Expr1112],0)))	12	3	2	Compute Scalar	Compute Scalar	DEFINE:([Expr1113]=CONVERT_IMPLICIT(decimal(18,5),[Expr1111],0), [Expr1114]=CONVERT_IMPLICIT(int,[Expr1112],0))	[Expr1113]=CONVERT_IMPLICIT(decimal(18,5),[Expr1111],0), [Expr1114]=CONVERT_IMPLICIT(int,[Expr1112],0)	1102,802	0	0,0001102802	40	6,089743	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1113], [Expr1114]	NULL	PLAN_ROW	0	1
1055	1	            |--Top(ROWCOUNT est 0)	12	4	3	Top	Top	TOP EXPRESSION:((0))	NULL	1102,802	0	0,0001102802	52	6,089633	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111], [Expr1112]	NULL	PLAN_ROW	0	1
1055	1	                 |--Sequence Project(DEFINE:([Expr1112]=row_number))	12	5	4	Sequence Project	Compute Scalar	DEFINE:([Expr1112]=row_number)	[Expr1112]=row_number	1102,802	0	8,822414E-05	52	6,089522	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111], [Expr1112]	NULL	PLAN_ROW	0	1
1055	1	                      |--Segment	12	6	5	Segment	Segment	[r].[StatsAccountID]	NULL	1102,802	0	2,205603E-05	52	6,089434	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111], [Segment1127]	NULL	PLAN_ROW	0	1
1055	1	                           |--Sort(ORDER BY:([r].[StatsAccountID] ASC, [r].[StartDate] ASC, [r].[EndDate] ASC))	12	7	6	Sort	Sort	ORDER BY:([r].[StatsAccountID] ASC, [r].[StartDate] ASC, [r].[EndDate] ASC)	NULL	1102,802	0,01126126	0,01748776	44	6,089412	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111]	NULL	PLAN_ROW	0	1
0	0	                                |--Compute Scalar(DEFINE:([Expr1111]=isnull([Expr1110],(0.000000))))	12	8	7	Compute Scalar	Compute Scalar	DEFINE:([Expr1111]=isnull([Expr1110],(0.000000)))	[Expr1111]=isnull([Expr1110],(0.000000))	1102,802	0	0,0001102802	44	6,060663	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111]	NULL	PLAN_ROW	0	1
0	0	                                     |--Compute Scalar(DEFINE:([Expr1110]=CASE WHEN [Expr1125]=(0) THEN NULL ELSE [Expr1126] END))	12	9	8	Compute Scalar	Compute Scalar	DEFINE:([Expr1110]=CASE WHEN [Expr1125]=(0) THEN NULL ELSE [Expr1126] END)	[Expr1110]=CASE WHEN [Expr1125]=(0) THEN NULL ELSE [Expr1126] END	1102,802	0	0,3762999	44	6,060553	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1110]	NULL	PLAN_ROW	0	1
1055	1	                                          |--Hash Match(Aggregate, HASH:([r].[StartDate], [r].[EndDate], [r].[StatsAccountID]), RESIDUAL:(@Ranges.[StartDate] as [r].[StartDate] = @Ranges.[StartDate] as [r].[StartDate] AND @Ranges.[EndDate] as [r].[EndDate] = @Ranges.[EndDate] as [r].[EndDate] AND @Ranges.[StatsAccountID] as [r].[StatsAccountID] = @Ranges.[StatsAccountID] as [r].[StatsAccountID]) DEFINE:([Expr1125]=COUNT_BIG(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0))), [Expr1126]=SUM(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0)))))	12	10	9	Hash Match	Aggregate	HASH:([r].[StartDate], [r].[EndDate], [r].[StatsAccountID]), RESIDUAL:(@Ranges.[StartDate] as [r].[StartDate] = @Ranges.[StartDate] as [r].[StartDate] AND @Ranges.[EndDate] as [r].[EndDate] = @Ranges.[EndDate] as [r].[EndDate] AND @Ranges.[StatsAccountID] as [r].[StatsAccountID] = @Ranges.[StatsAccountID] as [r].[StatsAccountID])	[Expr1125]=COUNT_BIG(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0))), [Expr1126]=SUM(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0)))	1102,802	0	0,3762999	44	6,060553	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1125], [Expr1126]	NULL	PLAN_ROW	0	1
3333	1	                                               |--Nested Loops(Left Outer Join, OUTER REFERENCES:([r].[EndDate], [Expr1014], [Expr1015]))	12	11	10	Nested Loops	Left Outer Join	OUTER REFERENCES:([r].[EndDate], [Expr1014], [Expr1015])	NULL	15411,5	0	0,04735688	333	5,684253	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1079], [Expr1080], [Expr1081], [Expr1082], [Expr1106], [Expr1107], [Expr1108], [Expr1109], [Expr1115]	NULL	PLAN_ROW	0	1
3333	1	                                                    |--Nested Loops(Left Outer Join, OUTER REFERENCES:([r].[EndDate], [Expr1014], [Expr1015]))	12	12	11	Nested Loops	Left Outer Join	OUTER REFERENCES:([r].[EndDate], [Expr1014], [Expr1015])	NULL	4123,335	0	0,0126703	302	4,292359	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [t].[Currency], [t].[Item], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1079], [Expr1080], [Expr1081], [Expr1082], [Expr1115]	NULL	PLAN_ROW	0	1
3333	1	                                                    |    |--Nested Loops(Left Outer Join, OUTER REFERENCES:([r].[EndDate], [Expr1015]))	12	13	12	Nested Loops	Left Outer Join	OUTER REFERENCES:([r].[EndDate], [Expr1015])	NULL	1103,195	0	0,0044099	249	3,685348	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [t].[Currency], [t].[Item], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1115]	NULL	PLAN_ROW	0	1
3333	1	                                                    |    |    |--Sort(ORDER BY:([r].[EndDate] ASC, [t].[Currency] ASC, [t].[Item] ASC))	12	14	13	Sort	Sort	ORDER BY:([r].[EndDate] ASC, [t].[Currency] ASC, [t].[Item] ASC)	NULL	1055	0,01126126	0,01662901	197	3,102351	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [t].[Currency], [t].[Item], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1115]	NULL	PLAN_ROW	0	1
3333	1	                                                    |    |    |    |--Hash Match(Left Outer Join, HASH:([r].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:((#TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]>=@Ranges.[StartDate] as [r].[StartDate] AND #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<=@Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<@Ranges.[StartDate] as [r].[StartDate]) AND @Ranges.[StatsAccountID] as [r].[StatsAccountID]=#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID] AND (#TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc]>@Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc] IS NULL)))	12	15	14	Hash Match	Left Outer Join	HASH:([r].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:((#TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]>=@Ranges.[StartDate] as [r].[StartDate] AND #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<=@Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<@Ranges.[StartDate] as [r].[StartDate]) AND @Ranges.[StatsAccountID] as [r].[StatsAccountID]=#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID] AND (#TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc]>@Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc] IS NULL))	NULL	1055	0	0,5920372	197	3,07446	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [t].[Currency], [t].[Item], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1115]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |    |         |--Compute Scalar(DEFINE:([Expr1115]=CONVERT(date,@Ranges.[EndDate] as [r].[EndDate],0)))	12	16	15	Compute Scalar	Compute Scalar	DEFINE:([Expr1115]=CONVERT(date,@Ranges.[EndDate] as [r].[EndDate],0))	[Expr1115]=CONVERT(date,@Ranges.[EndDate] as [r].[EndDate],0)	1055	0	0,0001055	30	0,006770222	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1115]	NULL	PLAN_ROW	0	1
1055	1	                                                    |    |    |         |    |--Clustered Index Scan(OBJECT:(@Ranges AS [r]))	12	17	16	Clustered Index Scan	Clustered Index Scan	OBJECT:(@Ranges AS [r])	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate]	1055	0,005347222	0,0013175	27	0,006664722	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |    |         |--Compute Scalar(DEFINE:([Expr1016]=isnull([razor_feeds].[dbo].[STS_StatsTicketsEquity].[Equity] as [e].[Equity],#TicketsTWR.[Profit] as [t].[Profit])))	12	21	15	Compute Scalar	Compute Scalar	DEFINE:([Expr1016]=isnull([razor_feeds].[dbo].[STS_StatsTicketsEquity].[Equity] as [e].[Equity],#TicketsTWR.[Profit] as [t].[Profit]))	[Expr1016]=isnull([razor_feeds].[dbo].[STS_StatsTicketsEquity].[Equity] as [e].[Equity],#TicketsTWR.[Profit] as [t].[Profit])	83272,02	0	0,008327202	194	2,475631	[t].[StatsAccountID], [t].[Currency], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021]	NULL	PLAN_ROW	0	1
95259	1	                                                    |    |    |              |--Hash Match(Right Outer Join, HASH:([e].[StatsTicketsId], [Expr1116])=([t].[StatsTicketsId], [Expr1117]), RESIDUAL:(#TicketsTWR.[StatsTicketsId] as [t].[StatsTicketsId]=[razor_feeds].[dbo].[STS_StatsTicketsEquity].[StatsTicketsId] as [e].[StatsTicketsId] AND [Expr1116]=[Expr1117]))	12	22	21	Hash Match	Right Outer Join	HASH:([e].[StatsTicketsId], [Expr1116])=([t].[StatsTicketsId], [Expr1117]), RESIDUAL:(#TicketsTWR.[StatsTicketsId] as [t].[StatsTicketsId]=[razor_feeds].[dbo].[STS_StatsTicketsEquity].[StatsTicketsId] as [e].[StatsTicketsId] AND [Expr1116]=[Expr1117])	NULL	83272,02	0	0,6531398	203	2,467304	[t].[StatsAccountID], [t].[Profit], [t].[Currency], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item], [e].[Equity], [Expr1014], [Expr1015], [Expr1017], [Expr1018], [Expr1021]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |    |                   |--Compute Scalar(DEFINE:([Expr1116]=CONVERT(date,dateadd(second,(-1),[razor_feeds].[dbo].[STS_StatsTicketsEquity].[TicketTime] as [e].[TicketTime]),0)))	12	23	22	Compute Scalar	Compute Scalar	DEFINE:([Expr1116]=CONVERT(date,dateadd(second,(-1),[razor_feeds].[dbo].[STS_StatsTicketsEquity].[TicketTime] as [e].[TicketTime]),0))	[Expr1116]=CONVERT(date,dateadd(second,(-1),[razor_feeds].[dbo].[STS_StatsTicketsEquity].[TicketTime] as [e].[TicketTime]),0)	1	0	1E-07	23	0,0032832	[e].[StatsTicketsId], [e].[Equity], [Expr1116]	NULL	PLAN_ROW	0	1
0	1	                                                    |    |    |                   |    |--Index Scan(OBJECT:([razor_feeds].[dbo].[STS_StatsTicketsEquity].[idx_StatsTicketsEquity_TicketId] AS [e]))	12	24	23	Index Scan	Index Scan	OBJECT:([razor_feeds].[dbo].[STS_StatsTicketsEquity].[idx_StatsTicketsEquity_TicketId] AS [e])	[e].[StatsTicketsId], [e].[TicketTime], [e].[Equity]	1	0,003125	0,0001581	28	0,0032831	[e].[StatsTicketsId], [e].[TicketTime], [e].[Equity]	NULL	PLAN_ROW	0	1
95259	1	                                                    |    |    |                   |--Hash Match(Inner Join, HASH:([a].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:(#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID]=#Account.[StatsAccountID] as [a].[StatsAccountID]))	12	28	22	Hash Match	Inner Join	HASH:([a].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:(#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID]=#Account.[StatsAccountID] as [a].[StatsAccountID])	NULL	83272,02	0	0,734146	201	1,810874	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[Currency], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item], [Expr1014], [Expr1015], [Expr1017], [Expr1018], [Expr1021], [Expr1117]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |    |                        |--Compute Scalar(DEFINE:([Expr1117]=CONVERT(date,#Account.[DateEnd] as [a].[DateEnd],0)))	12	29	28	Compute Scalar	Compute Scalar	DEFINE:([Expr1117]=CONVERT(date,#Account.[DateEnd] as [a].[DateEnd],0))	[Expr1117]=CONVERT(date,#Account.[DateEnd] as [a].[DateEnd],0)	165	0	1,65E-05	14	0,004961481	[a].[StatsAccountID], [Expr1117]	NULL	PLAN_ROW	0	1
165	1	                                                    |    |    |                        |    |--Table Scan(OBJECT:([tempdb].[dbo].[#Account] AS [a]))	12	30	29	Table Scan	Table Scan	OBJECT:([tempdb].[dbo].[#Account] AS [a])	[a].[StatsAccountID], [a].[DateEnd]	165	0,004606482	0,0003385	19	0,004944982	[a].[StatsAccountID], [a].[DateEnd]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |    |                        |--Compute Scalar(DEFINE:([Expr1014]=#TicketsTWR.[Currency] as [t].[Currency], [Expr1015]=#TicketsTWR.[Item] as [t].[Item], [Expr1017]=#TicketsTWR.[OpenPrice] as [t].[OpenPrice], [Expr1018]=#TicketsTWR.[Units] as [t].[Units], [Expr1021]=#TicketsTWR.[Type] as [t].[Type]))	12	34	28	Compute Scalar	Compute Scalar	DEFINE:([Expr1014]=#TicketsTWR.[Currency] as [t].[Currency], [Expr1015]=#TicketsTWR.[Item] as [t].[Item], [Expr1017]=#TicketsTWR.[OpenPrice] as [t].[OpenPrice], [Expr1018]=#TicketsTWR.[Units] as [t].[Units], [Expr1021]=#TicketsTWR.[Type] as [t].[Type])	[Expr1014]=#TicketsTWR.[Currency] as [t].[Currency], [Expr1015]=#TicketsTWR.[Item] as [t].[Item], [Expr1017]=#TicketsTWR.[OpenPrice] as [t].[OpenPrice], [Expr1018]=#TicketsTWR.[Units] as [t].[Units], [Expr1021]=#TicketsTWR.[Type] as [t].[Type]	95250,68	0	0,0096314	207	0,987007	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[Currency], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item], [Expr1014], [Expr1015], [Expr1017], [Expr1018], [Expr1021]	NULL	PLAN_ROW	0	1
95259	1	                                                    |    |    |                             |--Table Scan(OBJECT:([tempdb].[dbo].[#TicketsTWR] AS [t]), WHERE:(#TicketsTWR.[Type] as [t].[Type]<>N'balance' AND #TicketsTWR.[Type] as [t].[Type]<>N'credit'))	12	35	34	Table Scan	Table Scan	OBJECT:([tempdb].[dbo].[#TicketsTWR] AS [t]), WHERE:(#TicketsTWR.[Type] as [t].[Type]<>N'balance' AND #TicketsTWR.[Type] as [t].[Type]<>N'credit')	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[Type], [t].[Currency], [t].[OpenPrice], [t].[Units], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item]	95250,68	0,8712732	0,1061024	91	0,9773756	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[Type], [t].[Currency], [t].[OpenPrice], [t].[Units], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item]	NULL	PLAN_ROW	0	1
889	3333	                                                    |    |    |--Table Spool	12	53	13	Table Spool	Lazy Spool	NULL	NULL	1	0,01	0,00010058	59	0,5785878	[Expr1052], [Expr1053], [Expr1054], [Expr1055]	NULL	PLAN_ROW	0	1055
0	0	                                                    |    |         |--Compute Scalar(DEFINE:([Expr1052]=[Union1044], [Expr1053]=[Union1045], [Expr1054]=[Union1046], [Expr1055]=[Union1047]))	12	54	53	Compute Scalar	Compute Scalar	DEFINE:([Expr1052]=[Union1044], [Expr1053]=[Union1045], [Expr1054]=[Union1046], [Expr1055]=[Union1047])	[Expr1052]=[Union1044], [Expr1053]=[Union1045], [Expr1054]=[Union1046], [Expr1055]=[Union1047]	1	0	1E-07	59	0,1480773	[Expr1052], [Expr1053], [Expr1054], [Expr1055]	NULL	PLAN_ROW	0	32,48076
307	1777	                                                    |    |              |--Nested Loops(Inner Join, OUTER REFERENCES:([p].[PairID]))	12	55	54	Nested Loops	Inner Join	OUTER REFERENCES:([p].[PairID])	NULL	1	0	8,36E-06	59	0,148074	[Union1044], [Union1045], [Union1046], [Union1047]	NULL	PLAN_ROW	0	32,48076
1529	1777	                                                    |    |                   |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=[Expr1015]) ORDERED FORWARD)	12	56	55	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=[Expr1015]) ORDERED FORWARD	[p].[PairID]	1	0,003125	0,0001581	11	0,008260209	[p].[PairID]	NULL	PLAN_ROW	0	32,48076
307	1529	                                                    |    |                   |--Concatenation	12	57	55	Concatenation	Concatenation	NULL	[Union1044] = ([Expr1031], [Expr1038]), [Union1045] = ([Expr1032], [Expr1039]), [Union1046] = ([Expr1033], [Expr1040]), [Union1047] = ([Expr1034], [Expr1041])	2	0	2E-07	59	0,1395423	[Union1044], [Union1045], [Union1046], [Union1047]	NULL	PLAN_ROW	0	32,48076
0	0	                                                    |    |                        |--Compute Scalar(DEFINE:([Expr1031]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1032]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1033]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1034]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END))	12	58	57	Compute Scalar	Compute Scalar	DEFINE:([Expr1031]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1032]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1033]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1034]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END)	[Expr1031]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1032]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1033]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1034]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END	1	0	1E-07	59	0,06987629	[Expr1031], [Expr1032], [Expr1033], [Expr1034]	NULL	PLAN_ROW	0	32,48076
307	1529	                                                    |    |                        |    |--Clustered Index Seek(OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD)	12	59	58	Clustered Index Seek	Clustered Index Seek	OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	1	0,003125	0,0001581	65	0,06987304	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	NULL	PLAN_ROW	0	32,48076
0	0	                                                    |    |                        |--Compute Scalar(DEFINE:([Expr1038]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1039]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1040]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1041]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END))	12	69	57	Compute Scalar	Compute Scalar	DEFINE:([Expr1038]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1039]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1040]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1041]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END)	[Expr1038]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1039]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1040]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1041]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END	1	0	2,084084E-07	59	0,06965948	[Expr1038], [Expr1039], [Expr1040], [Expr1041]	NULL	PLAN_ROW	0	32,48076
0	1529	                                                    |    |                             |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD)	12	70	69	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	2,084084	0,003125	0,0001592925	65	0,06965271	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	NULL	PLAN_ROW	0	32,48076
166	3333	                                                    |    |--Table Spool	12	89	12	Table Spool	Lazy Spool	NULL	NULL	2,747629	0,01	0,0001008946	59	0,5943403	[Expr1079], [Expr1080], [Expr1081], [Expr1082]	NULL	PLAN_ROW	0	1103,195
0	0	                                                    |         |--Compute Scalar(DEFINE:([Expr1079]=[Union1071], [Expr1080]=[Union1072], [Expr1081]=[Union1073], [Expr1082]=[Union1074]))	12	90	89	Compute Scalar	Compute Scalar	DEFINE:([Expr1079]=[Union1071], [Expr1080]=[Union1072], [Expr1081]=[Union1073], [Expr1082]=[Union1074])	[Expr1079]=[Union1071], [Expr1080]=[Union1072], [Expr1081]=[Union1073], [Expr1082]=[Union1074]	2,747629	0	1E-07	59	0,1513181	[Expr1079], [Expr1080], [Expr1081], [Expr1082]	NULL	PLAN_ROW	0	33,21438
102	1777	                                                    |              |--Nested Loops(Inner Join, OUTER REFERENCES:([p].[PairID]))	12	91	90	Nested Loops	Inner Join	OUTER REFERENCES:([p].[PairID])	NULL	1	0	8,36E-06	59	0,1513148	[Union1071], [Union1072], [Union1073], [Union1074]	NULL	PLAN_ROW	0	33,21438
196	1777	                                                    |                   |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=right([Expr1015],(3))+[Expr1014]) ORDERED FORWARD)	12	92	91	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=right([Expr1015],(3))+[Expr1014]) ORDERED FORWARD	[p].[PairID]	1	0,003125	0,0001581	11	0,008376194	[p].[PairID]	NULL	PLAN_ROW	0	33,21438
102	196	                                                    |                   |--Concatenation	12	93	91	Concatenation	Concatenation	NULL	[Union1071] = ([Expr1058], [Expr1065]), [Union1072] = ([Expr1059], [Expr1066]), [Union1073] = ([Expr1060], [Expr1067]), [Union1074] = ([Expr1061], [Expr1068])	2	0	2E-07	59	0,1426609	[Union1071], [Union1072], [Union1073], [Union1074]	NULL	PLAN_ROW	0	33,21438
0	0	                                                    |                        |--Compute Scalar(DEFINE:([Expr1058]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1059]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1060]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1061]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END))	12	94	93	Compute Scalar	Compute Scalar	DEFINE:([Expr1058]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1059]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1060]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1061]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END)	[Expr1058]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1059]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1060]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1061]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END	1	0	1E-07	59	0,07144107	[Expr1058], [Expr1059], [Expr1060], [Expr1061]	NULL	PLAN_ROW	0	33,21438
102	196	                                                    |                        |    |--Clustered Index Seek(OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD)	12	95	94	Clustered Index Seek	Clustered Index Seek	OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	1	0,003125	0,0001581	65	0,07143775	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	NULL	PLAN_ROW	0	33,21438
0	0	                                                    |                        |--Compute Scalar(DEFINE:([Expr1065]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1066]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1067]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1068]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END))	12	105	93	Compute Scalar	Compute Scalar	DEFINE:([Expr1065]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1066]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1067]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1068]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END)	[Expr1065]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1066]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1067]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1068]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END	1	0	2,084084E-07	59	0,07121321	[Expr1065], [Expr1066], [Expr1067], [Expr1068]	NULL	PLAN_ROW	0	33,21438
0	196	                                                    |                             |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD)	12	106	105	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	2,084084	0,003125	0,0001592925	65	0,07120629	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	NULL	PLAN_ROW	0	33,21438
482	3333	                                                    |--Table Spool	12	125	11	Table Spool	Lazy Spool	NULL	NULL	2,747629	0,01	0,0001008946	59	1,344537	[Expr1106], [Expr1107], [Expr1108], [Expr1109]	NULL	PLAN_ROW	0	4123,335
0	0	                                                         |--Compute Scalar(DEFINE:([Expr1106]=[Union1098], [Expr1107]=[Union1099], [Expr1108]=[Union1100], [Expr1109]=[Union1101]))	12	126	125	Compute Scalar	Compute Scalar	DEFINE:([Expr1106]=[Union1098], [Expr1107]=[Union1099], [Expr1108]=[Union1100], [Expr1109]=[Union1101])	[Expr1106]=[Union1098], [Expr1107]=[Union1099], [Expr1108]=[Union1100], [Expr1109]=[Union1101]	2,747629	0	1E-07	59	0,2880065	[Expr1106], [Expr1107], [Expr1108], [Expr1109]	NULL	PLAN_ROW	0	64,2132
144	1777	                                                              |--Nested Loops(Inner Join, OUTER REFERENCES:([p].[PairID]))	12	127	126	Nested Loops	Inner Join	OUTER REFERENCES:([p].[PairID])	NULL	1	0	8,36E-06	59	0,2880001	[Union1098], [Union1099], [Union1100], [Union1101]	NULL	PLAN_ROW	0	64,2132
961	1777	                                                                   |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=[Expr1014]+right([Expr1015],(3))) ORDERED FORWARD)	12	128	127	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=[Expr1014]+right([Expr1015],(3))) ORDERED FORWARD	[p].[PairID]	1	0,003125	0,0001581	11	0,01327711	[p].[PairID]	NULL	PLAN_ROW	0	64,2132
144	961	                                                                   |--Concatenation	12	129	127	Concatenation	Concatenation	NULL	[Union1098] = ([Expr1085], [Expr1092]), [Union1099] = ([Expr1086], [Expr1093]), [Union1100] = ([Expr1087], [Expr1094]), [Union1101] = ([Expr1088], [Expr1095])	2	0	2E-07	59	0,2741862	[Union1098], [Union1099], [Union1100], [Union1101]	NULL	PLAN_ROW	0	64,2132
0	0	                                                                        |--Compute Scalar(DEFINE:([Expr1085]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1086]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1087]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1088]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END))	12	130	129	Compute Scalar	Compute Scalar	DEFINE:([Expr1085]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1086]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1087]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1088]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END)	[Expr1085]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1086]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1087]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1088]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END	1	0	1E-07	59	0,1375577	[Expr1085], [Expr1086], [Expr1087], [Expr1088]	NULL	PLAN_ROW	0	64,2132
144	961	                                                                        |    |--Clustered Index Seek(OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD)	12	131	130	Clustered Index Seek	Clustered Index Seek	OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	1	0,003125	0,0001581	65	0,1375513	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	NULL	PLAN_ROW	0	64,2132
0	0	                                                                        |--Compute Scalar(DEFINE:([Expr1092]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1093]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1094]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1095]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END))	12	141	129	Compute Scalar	Compute Scalar	DEFINE:([Expr1092]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1093]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1094]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1095]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END)	[Expr1092]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1093]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1094]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1095]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END	1	0	2,084084E-07	59	0,1366156	[Expr1092], [Expr1093], [Expr1094], [Expr1095]	NULL	PLAN_ROW	0	64,2132
0	961	                                                                             |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD)	12	142	141	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=@Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	2,084084	0,003125	0,0001592925	65	0,1366023	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	NULL	PLAN_ROW	0	64,2132
8 фев 13, 16:51    [13899057]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
+ Временная таблица
1055	1	  |--Table Insert(OBJECT:(@Equities), SET:([StatsAccountID] = #Ranges.[StatsAccountID] as [r].[StatsAccountID],[StartDate] = #Ranges.[StartDate] as [r].[StartDate],[EndDate] = #Ranges.[EndDate] as [r].[EndDate],[Profit] = [Expr1113],[RowNum] = [Expr1114]))	15	2	1	Table Insert	Insert	OBJECT:(@Equities), SET:([StatsAccountID] = #Ranges.[StatsAccountID] as [r].[StatsAccountID],[StartDate] = #Ranges.[StartDate] as [r].[StartDate],[EndDate] = #Ranges.[EndDate] as [r].[EndDate],[Profit] = [Expr1113],[RowNum] = [Expr1114])	NULL	410,4832	0,0167859	0,0004104832	9	789,3729	NULL	NULL	PLAN_ROW	0	1
0	0	       |--Compute Scalar(DEFINE:([Expr1113]=CONVERT_IMPLICIT(decimal(18,5),[Expr1111],0), [Expr1114]=CONVERT_IMPLICIT(int,[Expr1112],0)))	15	3	2	Compute Scalar	Compute Scalar	DEFINE:([Expr1113]=CONVERT_IMPLICIT(decimal(18,5),[Expr1111],0), [Expr1114]=CONVERT_IMPLICIT(int,[Expr1112],0))	[Expr1113]=CONVERT_IMPLICIT(decimal(18,5),[Expr1111],0), [Expr1114]=CONVERT_IMPLICIT(int,[Expr1112],0)	410,4832	0	4,104833E-05	40	789,3557	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1113], [Expr1114]	NULL	PLAN_ROW	0	1
1055	1	            |--Top(ROWCOUNT est 0)	15	4	3	Top	Top	TOP EXPRESSION:((0))	NULL	410,4832	0	4,104833E-05	52	789,3557	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111], [Expr1112]	NULL	PLAN_ROW	0	1
1055	1	                 |--Sequence Project(DEFINE:([Expr1112]=row_number))	15	5	4	Sequence Project	Compute Scalar	DEFINE:([Expr1112]=row_number)	[Expr1112]=row_number	410,4832	0	3,283866E-05	52	789,3556	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111], [Expr1112]	NULL	PLAN_ROW	0	1
1055	1	                      |--Segment	15	6	5	Segment	Segment	[r].[StatsAccountID]	NULL	410,4832	0	8,209665E-06	52	789,3556	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111], [Segment1126]	NULL	PLAN_ROW	0	1
1055	1	                           |--Sort(ORDER BY:([r].[StatsAccountID] ASC, [r].[StartDate] ASC, [r].[EndDate] ASC))	15	7	6	Sort	Sort	ORDER BY:([r].[StatsAccountID] ASC, [r].[StartDate] ASC, [r].[EndDate] ASC)	NULL	410,4832	0,01126126	0,005659071	44	789,3555	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111]	NULL	PLAN_ROW	0	1
0	0	                                |--Compute Scalar(DEFINE:([Expr1111]=isnull([Expr1110],(0.000000))))	15	8	7	Compute Scalar	Compute Scalar	DEFINE:([Expr1111]=isnull([Expr1110],(0.000000)))	[Expr1111]=isnull([Expr1110],(0.000000))	410,4832	0	4,104833E-05	44	789,3386	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1111]	NULL	PLAN_ROW	0	1
0	0	                                     |--Compute Scalar(DEFINE:([Expr1110]=CASE WHEN [Expr1124]=(0) THEN NULL ELSE [Expr1125] END))	15	9	8	Compute Scalar	Compute Scalar	DEFINE:([Expr1110]=CASE WHEN [Expr1124]=(0) THEN NULL ELSE [Expr1125] END)	[Expr1110]=CASE WHEN [Expr1124]=(0) THEN NULL ELSE [Expr1125] END	410,4832	0	118,792	44	789,3386	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1110]	NULL	PLAN_ROW	0	1
1055	1	                                          |--Hash Match(Aggregate, HASH:([r].[StartDate], [r].[EndDate], [r].[StatsAccountID]), RESIDUAL:(#Ranges.[StartDate] as [r].[StartDate] = #Ranges.[StartDate] as [r].[StartDate] AND #Ranges.[EndDate] as [r].[EndDate] = #Ranges.[EndDate] as [r].[EndDate] AND #Ranges.[StatsAccountID] as [r].[StatsAccountID] = #Ranges.[StatsAccountID] as [r].[StatsAccountID]) DEFINE:([Expr1124]=COUNT_BIG(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0))), [Expr1125]=SUM(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0)))))	15	10	9	Hash Match	Aggregate	HASH:([r].[StartDate], [r].[EndDate], [r].[StatsAccountID]), RESIDUAL:(#Ranges.[StartDate] as [r].[StartDate] = #Ranges.[StartDate] as [r].[StartDate] AND #Ranges.[EndDate] as [r].[EndDate] = #Ranges.[EndDate] as [r].[EndDate] AND #Ranges.[StatsAccountID] as [r].[StatsAccountID] = #Ranges.[StatsAccountID] as [r].[StatsAccountID])	[Expr1124]=COUNT_BIG(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0))), [Expr1125]=SUM(isnull(CASE WHEN [Expr1115]=[@Today] THEN NULL ELSE CASE WHEN CASE WHEN [Expr1021] like N'sell%' THEN (1) ELSE (0) END=(1) THEN (([Expr1017]-([Expr1052]+[Expr1053])/(2.))*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1079]+[Expr1080])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1106]+[Expr1107])/(2.)),0)) END ELSE CASE WHEN CASE WHEN [Expr1021] like N'buy%' THEN (1) ELSE (0) END=(1) THEN ((([Expr1054]+[Expr1055])/(2.)-[Expr1017])*[Expr1018])*CASE WHEN CASE WHEN right([Expr1015],(3))=[Expr1014] THEN (1) ELSE (0) END=(1) THEN (1.000000000) ELSE isnull(([Expr1081]+[Expr1082])/(2.),CONVERT_IMPLICIT(decimal(24,9),(1.)/(([Expr1108]+[Expr1109])/(2.)),0)) END ELSE NULL END END END,CONVERT_IMPLICIT(decimal(38,6),[Expr1016],0)))	410,4832	0	118,792	44	789,3386	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1124], [Expr1125]	NULL	PLAN_ROW	0	1
3333	1	                                               |--Nested Loops(Left Outer Join, OUTER REFERENCES:([r].[EndDate], [Expr1014], [Expr1015]))	15	11	10	Nested Loops	Left Outer Join	OUTER REFERENCES:([r].[EndDate], [Expr1014], [Expr1015])	NULL	1,777014E+07	0	26,24616	333	670,5466	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1079], [Expr1080], [Expr1081], [Expr1082], [Expr1106], [Expr1107], [Expr1108], [Expr1109], [Expr1115]	NULL	PLAN_ROW	0	1
3333	1	                                                    |--Hash Match(Left Outer Join, HASH:([Expr1118], [r].[EndDate])=([p].[Symbol], [Union1069]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[Symbol] as [p].[Symbol]=[Expr1118] AND [Union1069]=#Ranges.[EndDate] as [r].[EndDate]))	15	12	11	Hash Match	Left Outer Join	HASH:([Expr1118], [r].[EndDate])=([p].[Symbol], [Union1069]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[Symbol] as [p].[Symbol]=[Expr1118] AND [Union1069]=#Ranges.[EndDate] as [r].[EndDate])	NULL	2285238	104,8297	119,9915	281	414,6266	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1079], [Expr1080], [Expr1081], [Expr1082], [Expr1115]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |--Compute Scalar(DEFINE:([Expr1118]=right([Expr1015],(3))+[Expr1014]))	15	13	12	Compute Scalar	Compute Scalar	DEFINE:([Expr1118]=right([Expr1015],(3))+[Expr1014])	[Expr1118]=right([Expr1015],(3))+[Expr1014]	582982,6	0	0,05829826	243	139,3798	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1115], [Expr1118]	NULL	PLAN_ROW	0	1
3333	1	                                                    |    |    |--Hash Match(Left Outer Join, HASH:([Expr1015], [r].[EndDate])=([p].[Symbol], [Union1042]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[Symbol] as [p].[Symbol]=[Expr1015] AND [Union1042]=#Ranges.[EndDate] as [r].[EndDate]))	15	14	13	Hash Match	Left Outer Join	HASH:([Expr1015], [r].[EndDate])=([p].[Symbol], [Union1042]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[Symbol] as [p].[Symbol]=[Expr1015] AND [Union1042]=#Ranges.[EndDate] as [r].[EndDate])	NULL	582982,6	0	85,11973	228	139,3215	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1052], [Expr1053], [Expr1054], [Expr1055], [Expr1115]	NULL	PLAN_ROW	0	1
3333	1	                                                    |    |         |--Hash Match(Left Outer Join, HASH:([r].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:((#TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]>=#Ranges.[StartDate] as [r].[StartDate] AND #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<=#Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<#Ranges.[StartDate] as [r].[StartDate]) AND #Ranges.[StatsAccountID] as [r].[StatsAccountID]=#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID] AND (#TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc]>#Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc] IS NULL)))	15	15	14	Hash Match	Left Outer Join	HASH:([r].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:((#TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]>=#Ranges.[StartDate] as [r].[StartDate] AND #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<=#Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[OpenTimeUtc] as [t].[OpenTimeUtc]<#Ranges.[StartDate] as [r].[StartDate]) AND #Ranges.[StatsAccountID] as [r].[StatsAccountID]=#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID] AND (#TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc]>#Ranges.[EndDate] as [r].[EndDate] OR #TicketsTWR.[CloseTimeUtc] as [t].[CloseTimeUtc] IS NULL))	NULL	538305,1	0	1,293701	176	3,776124	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021], [Expr1115]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |         |    |--Compute Scalar(DEFINE:([Expr1115]=CONVERT(date,#Ranges.[EndDate] as [r].[EndDate],0)))	15	16	15	Compute Scalar	Compute Scalar	DEFINE:([Expr1115]=CONVERT(date,#Ranges.[EndDate] as [r].[EndDate],0))	[Expr1115]=CONVERT(date,#Ranges.[EndDate] as [r].[EndDate],0)	1055	0	0,0001055	30	0,006770222	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate], [Expr1115]	NULL	PLAN_ROW	0	1
1055	1	                                                    |    |         |    |    |--Clustered Index Scan(OBJECT:([tempdb].[dbo].[#Ranges] AS [r]))	15	17	16	Clustered Index Scan	Clustered Index Scan	OBJECT:([tempdb].[dbo].[#Ranges] AS [r])	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate]	1055	0,005347222	0,0013175	27	0,006664722	[r].[StatsAccountID], [r].[StartDate], [r].[EndDate]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |         |    |--Compute Scalar(DEFINE:([Expr1016]=isnull([razor_feeds].[dbo].[STS_StatsTicketsEquity].[Equity] as [e].[Equity],#TicketsTWR.[Profit] as [t].[Profit])))	15	21	15	Compute Scalar	Compute Scalar	DEFINE:([Expr1016]=isnull([razor_feeds].[dbo].[STS_StatsTicketsEquity].[Equity] as [e].[Equity],#TicketsTWR.[Profit] as [t].[Profit]))	[Expr1016]=isnull([razor_feeds].[dbo].[STS_StatsTicketsEquity].[Equity] as [e].[Equity],#TicketsTWR.[Profit] as [t].[Profit])	83272,02	0	0,008327202	173	2,475631	[t].[StatsAccountID], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [Expr1014], [Expr1015], [Expr1016], [Expr1017], [Expr1018], [Expr1021]	NULL	PLAN_ROW	0	1
95259	1	                                                    |    |         |         |--Hash Match(Right Outer Join, HASH:([e].[StatsTicketsId], [Expr1116])=([t].[StatsTicketsId], [Expr1117]), RESIDUAL:(#TicketsTWR.[StatsTicketsId] as [t].[StatsTicketsId]=[razor_feeds].[dbo].[STS_StatsTicketsEquity].[StatsTicketsId] as [e].[StatsTicketsId] AND [Expr1116]=[Expr1117]))	15	22	21	Hash Match	Right Outer Join	HASH:([e].[StatsTicketsId], [Expr1116])=([t].[StatsTicketsId], [Expr1117]), RESIDUAL:(#TicketsTWR.[StatsTicketsId] as [t].[StatsTicketsId]=[razor_feeds].[dbo].[STS_StatsTicketsEquity].[StatsTicketsId] as [e].[StatsTicketsId] AND [Expr1116]=[Expr1117])	NULL	83272,02	0	0,6531398	182	2,467304	[t].[StatsAccountID], [t].[Profit], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [e].[Equity], [Expr1014], [Expr1015], [Expr1017], [Expr1018], [Expr1021]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |         |              |--Compute Scalar(DEFINE:([Expr1116]=CONVERT(date,dateadd(second,(-1),[razor_feeds].[dbo].[STS_StatsTicketsEquity].[TicketTime] as [e].[TicketTime]),0)))	15	23	22	Compute Scalar	Compute Scalar	DEFINE:([Expr1116]=CONVERT(date,dateadd(second,(-1),[razor_feeds].[dbo].[STS_StatsTicketsEquity].[TicketTime] as [e].[TicketTime]),0))	[Expr1116]=CONVERT(date,dateadd(second,(-1),[razor_feeds].[dbo].[STS_StatsTicketsEquity].[TicketTime] as [e].[TicketTime]),0)	1	0	1E-07	23	0,0032832	[e].[StatsTicketsId], [e].[Equity], [Expr1116]	NULL	PLAN_ROW	0	1
0	1	                                                    |    |         |              |    |--Index Scan(OBJECT:([razor_feeds].[dbo].[STS_StatsTicketsEquity].[idx_StatsTicketsEquity_TicketId] AS [e]))	15	24	23	Index Scan	Index Scan	OBJECT:([razor_feeds].[dbo].[STS_StatsTicketsEquity].[idx_StatsTicketsEquity_TicketId] AS [e])	[e].[StatsTicketsId], [e].[TicketTime], [e].[Equity]	1	0,003125	0,0001581	28	0,0032831	[e].[StatsTicketsId], [e].[TicketTime], [e].[Equity]	NULL	PLAN_ROW	0	1
95259	1	                                                    |    |         |              |--Hash Match(Inner Join, HASH:([a].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:(#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID]=#Account.[StatsAccountID] as [a].[StatsAccountID]))	15	28	22	Hash Match	Inner Join	HASH:([a].[StatsAccountID])=([t].[StatsAccountID]), RESIDUAL:(#TicketsTWR.[StatsAccountID] as [t].[StatsAccountID]=#Account.[StatsAccountID] as [a].[StatsAccountID])	NULL	83272,02	0	0,734146	180	1,810874	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [Expr1014], [Expr1015], [Expr1017], [Expr1018], [Expr1021], [Expr1117]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |         |                   |--Compute Scalar(DEFINE:([Expr1117]=CONVERT(date,#Account.[DateEnd] as [a].[DateEnd],0)))	15	29	28	Compute Scalar	Compute Scalar	DEFINE:([Expr1117]=CONVERT(date,#Account.[DateEnd] as [a].[DateEnd],0))	[Expr1117]=CONVERT(date,#Account.[DateEnd] as [a].[DateEnd],0)	165	0	1,65E-05	14	0,004961481	[a].[StatsAccountID], [Expr1117]	NULL	PLAN_ROW	0	1
165	1	                                                    |    |         |                   |    |--Table Scan(OBJECT:([tempdb].[dbo].[#Account] AS [a]))	15	30	29	Table Scan	Table Scan	OBJECT:([tempdb].[dbo].[#Account] AS [a])	[a].[StatsAccountID], [a].[DateEnd]	165	0,004606482	0,0003385	19	0,004944982	[a].[StatsAccountID], [a].[DateEnd]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |         |                   |--Compute Scalar(DEFINE:([Expr1014]=#TicketsTWR.[Currency] as [t].[Currency], [Expr1015]=#TicketsTWR.[Item] as [t].[Item], [Expr1017]=#TicketsTWR.[OpenPrice] as [t].[OpenPrice], [Expr1018]=#TicketsTWR.[Units] as [t].[Units], [Expr1021]=#TicketsTWR.[Type] as [t].[Type]))	15	34	28	Compute Scalar	Compute Scalar	DEFINE:([Expr1014]=#TicketsTWR.[Currency] as [t].[Currency], [Expr1015]=#TicketsTWR.[Item] as [t].[Item], [Expr1017]=#TicketsTWR.[OpenPrice] as [t].[OpenPrice], [Expr1018]=#TicketsTWR.[Units] as [t].[Units], [Expr1021]=#TicketsTWR.[Type] as [t].[Type])	[Expr1014]=#TicketsTWR.[Currency] as [t].[Currency], [Expr1015]=#TicketsTWR.[Item] as [t].[Item], [Expr1017]=#TicketsTWR.[OpenPrice] as [t].[OpenPrice], [Expr1018]=#TicketsTWR.[Units] as [t].[Units], [Expr1021]=#TicketsTWR.[Type] as [t].[Type]	95250,68	0	0,0096314	186	0,987007	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [Expr1014], [Expr1015], [Expr1017], [Expr1018], [Expr1021]	NULL	PLAN_ROW	0	1
95259	1	                                                    |    |         |                        |--Table Scan(OBJECT:([tempdb].[dbo].[#TicketsTWR] AS [t]), WHERE:(#TicketsTWR.[Type] as [t].[Type]<>N'balance' AND #TicketsTWR.[Type] as [t].[Type]<>N'credit'))	15	35	34	Table Scan	Table Scan	OBJECT:([tempdb].[dbo].[#TicketsTWR] AS [t]), WHERE:(#TicketsTWR.[Type] as [t].[Type]<>N'balance' AND #TicketsTWR.[Type] as [t].[Type]<>N'credit')	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[Type], [t].[Currency], [t].[OpenPrice], [t].[Units], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item]	95250,68	0,8712732	0,1061024	91	0,9773756	[t].[StatsAccountID], [t].[Profit], [t].[StatsTicketsId], [t].[Type], [t].[Currency], [t].[OpenPrice], [t].[Units], [t].[OpenTimeUtc], [t].[CloseTimeUtc], [t].[Item]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |         |--Compute Scalar(DEFINE:([Expr1052]=[Union1044], [Expr1053]=[Union1045], [Expr1054]=[Union1046], [Expr1055]=[Union1047]))	15	53	14	Compute Scalar	Compute Scalar	DEFINE:([Expr1052]=[Union1044], [Expr1053]=[Union1045], [Expr1054]=[Union1046], [Expr1055]=[Union1047])	[Expr1052]=[Union1044], [Expr1053]=[Union1045], [Expr1054]=[Union1046], [Expr1055]=[Union1047]	2728424	0	0,2728423	83	50,42562	[Union1042], [p].[Symbol], [Expr1052], [Expr1053], [Expr1054], [Expr1055]	NULL	PLAN_ROW	0	1
3704272	1	                                                    |    |              |--Concatenation	15	54	53	Concatenation	Concatenation	NULL	[Union1042] = ([a].[CandleDateTime], [af].[CandleDateTime]), [Union1044] = ([Expr1031], [Expr1038]), [Union1045] = ([Expr1032], [Expr1039]), [Union1046] = ([Expr1033], [Expr1040]), [Union1047] = ([Expr1034], [Expr1041]), [p].[Symbol] = ([p].[Symbol], [p].[Symbol])	2728424	0	0,2728423	83	50,15278	[Union1042], [Union1044], [Union1045], [Union1046], [Union1047], [p].[Symbol]	NULL	PLAN_ROW	0	1
3542836	1	                                                    |    |                   |--Merge Join(Inner Join, MERGE:([p].[PairID])=([a].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConCandles1M].[PairID] as [a].[PairID]))	15	55	54	Merge Join	Inner Join	MERGE:([p].[PairID])=([a].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConCandles1M].[PairID] as [a].[PairID])	NULL	2609241	0	7,706589	83	47,49276	[a].[CandleDateTime], [Expr1031], [Expr1032], [Expr1033], [Expr1034], [p].[Symbol]	NULL	PLAN_ROW	0	1
52	1	                                                    |    |                   |    |--Clustered Index Scan(OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD)	15	56	55	Clustered Index Scan	Clustered Index Scan	OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD	[p].[PairID], [p].[Symbol]	52	0,003125	0,0002142	27	0,0033392	[p].[PairID], [p].[Symbol]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |                   |    |--Compute Scalar(DEFINE:([Expr1031]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1032]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1033]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1034]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END))	15	57	55	Compute Scalar	Compute Scalar	DEFINE:([Expr1031]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1032]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1033]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1034]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END)	[Expr1031]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1032]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1033]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1034]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END	3542836	0	0,3542836	71	39,78283	[a].[PairID], [a].[CandleDateTime], [Expr1031], [Expr1032], [Expr1033], [Expr1034]	NULL	PLAN_ROW	0	1
3542836	1	                                                    |    |                   |         |--Index Scan(OBJECT:([razor_feeds].[dbo].[eConCandles1M].[UK_eConCandles1M_CandleDateTime_PairID] AS [a]), ORDERED FORWARD)	15	58	57	Index Scan	Index Scan	OBJECT:([razor_feeds].[dbo].[eConCandles1M].[UK_eConCandles1M_CandleDateTime_PairID] AS [a]), ORDERED FORWARD	[a].[PairID], [a].[BrokerServerID], [a].[CandleDateTime], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	3542836	35,53127	3,897277	78	39,42855	[a].[PairID], [a].[BrokerServerID], [a].[CandleDateTime], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	NULL	PLAN_ROW	0	1
161436	1	                                                    |    |                   |--Merge Join(Inner Join, MERGE:([p].[PairID])=([af].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConQuotesFlat1M].[PairID] as [af].[PairID]))	15	69	54	Merge Join	Inner Join	MERGE:([p].[PairID])=([af].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConQuotesFlat1M].[PairID] as [af].[PairID])	NULL	119182,5	0	0,3904636	83	2,387174	[af].[CandleDateTime], [Expr1038], [Expr1039], [Expr1040], [Expr1041], [p].[Symbol]	NULL	PLAN_ROW	0	1
52	1	                                                    |    |                        |--Clustered Index Scan(OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD)	15	70	69	Clustered Index Scan	Clustered Index Scan	OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD	[p].[PairID], [p].[Symbol]	52	0,003125	0,0002142	27	0,0033392	[p].[PairID], [p].[Symbol]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |                        |--Compute Scalar(DEFINE:([Expr1038]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1039]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1040]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1041]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END))	15	71	69	Compute Scalar	Compute Scalar	DEFINE:([Expr1038]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1039]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1040]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1041]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END)	[Expr1038]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1039]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1040]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1041]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END	177541	0	0,0177541	71	1,993368	[af].[PairID], [af].[CandleDateTime], [Expr1038], [Expr1039], [Expr1040], [Expr1041]	NULL	PLAN_ROW	0	1
161437	1	                                                    |    |                             |--Index Scan(OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlatAsk1M_PairdID_CandleDateTime] AS [af]), ORDERED FORWARD)	15	72	71	Index Scan	Index Scan	OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlatAsk1M_PairdID_CandleDateTime] AS [af]), ORDERED FORWARD	[af].[PairID], [af].[BrokerServerID], [af].[CandleDateTime], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	177541	1,780162	0,1954521	78	1,975614	[af].[PairID], [af].[BrokerServerID], [af].[CandleDateTime], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	NULL	PLAN_ROW	0	1
0	0	                                                    |    |--Compute Scalar(DEFINE:([Expr1079]=[Union1071], [Expr1080]=[Union1072], [Expr1081]=[Union1073], [Expr1082]=[Union1074]))	15	96	12	Compute Scalar	Compute Scalar	DEFINE:([Expr1079]=[Union1071], [Expr1080]=[Union1072], [Expr1081]=[Union1073], [Expr1082]=[Union1074])	[Expr1079]=[Union1071], [Expr1080]=[Union1072], [Expr1081]=[Union1073], [Expr1082]=[Union1074]	2728424	0	0,2728423	83	50,42562	[Union1069], [p].[Symbol], [Expr1079], [Expr1080], [Expr1081], [Expr1082]	NULL	PLAN_ROW	0	1
3704272	1	                                                    |         |--Concatenation	15	97	96	Concatenation	Concatenation	NULL	[Union1069] = ([a].[CandleDateTime], [af].[CandleDateTime]), [Union1071] = ([Expr1058], [Expr1065]), [Union1072] = ([Expr1059], [Expr1066]), [Union1073] = ([Expr1060], [Expr1067]), [Union1074] = ([Expr1061], [Expr1068]), [p].[Symbol] = ([p].[Symbol], [p].[Symbol])	2728424	0	0,2728423	83	50,15278	[Union1069], [Union1071], [Union1072], [Union1073], [Union1074], [p].[Symbol]	NULL	PLAN_ROW	0	1
3542836	1	                                                    |              |--Merge Join(Inner Join, MERGE:([p].[PairID])=([a].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConCandles1M].[PairID] as [a].[PairID]))	15	98	97	Merge Join	Inner Join	MERGE:([p].[PairID])=([a].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConCandles1M].[PairID] as [a].[PairID])	NULL	2609241	0	7,706589	83	47,49276	[a].[CandleDateTime], [Expr1058], [Expr1059], [Expr1060], [Expr1061], [p].[Symbol]	NULL	PLAN_ROW	0	1
52	1	                                                    |              |    |--Clustered Index Scan(OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD)	15	99	98	Clustered Index Scan	Clustered Index Scan	OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD	[p].[PairID], [p].[Symbol]	52	0,003125	0,0002142	27	0,0033392	[p].[PairID], [p].[Symbol]	NULL	PLAN_ROW	0	1
0	0	                                                    |              |    |--Compute Scalar(DEFINE:([Expr1058]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1059]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1060]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1061]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END))	15	100	98	Compute Scalar	Compute Scalar	DEFINE:([Expr1058]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1059]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1060]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1061]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END)	[Expr1058]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1059]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1060]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1061]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END	3542836	0	0,3542836	71	39,78283	[a].[PairID], [a].[CandleDateTime], [Expr1058], [Expr1059], [Expr1060], [Expr1061]	NULL	PLAN_ROW	0	1
3542836	1	                                                    |              |         |--Index Scan(OBJECT:([razor_feeds].[dbo].[eConCandles1M].[UK_eConCandles1M_CandleDateTime_PairID] AS [a]), ORDERED FORWARD)	15	101	100	Index Scan	Index Scan	OBJECT:([razor_feeds].[dbo].[eConCandles1M].[UK_eConCandles1M_CandleDateTime_PairID] AS [a]), ORDERED FORWARD	[a].[PairID], [a].[BrokerServerID], [a].[CandleDateTime], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	3542836	35,53127	3,897277	78	39,42855	[a].[PairID], [a].[BrokerServerID], [a].[CandleDateTime], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	NULL	PLAN_ROW	0	1
161436	1	                                                    |              |--Merge Join(Inner Join, MERGE:([p].[PairID])=([af].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConQuotesFlat1M].[PairID] as [af].[PairID]))	15	112	97	Merge Join	Inner Join	MERGE:([p].[PairID])=([af].[PairID]), RESIDUAL:([razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]=[razor_feeds].[dbo].[eConQuotesFlat1M].[PairID] as [af].[PairID])	NULL	119182,5	0	0,3904636	83	2,387174	[af].[CandleDateTime], [Expr1065], [Expr1066], [Expr1067], [Expr1068], [p].[Symbol]	NULL	PLAN_ROW	0	1
52	1	                                                    |                   |--Clustered Index Scan(OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD)	15	113	112	Clustered Index Scan	Clustered Index Scan	OBJECT:([razor_feeds].[dbo].[eConPairs].[PK_eConPairs] AS [p]), ORDERED FORWARD	[p].[PairID], [p].[Symbol]	52	0,003125	0,0002142	27	0,0033392	[p].[PairID], [p].[Symbol]	NULL	PLAN_ROW	0	1
0	0	                                                    |                   |--Compute Scalar(DEFINE:([Expr1065]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1066]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1067]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1068]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END))	15	114	112	Compute Scalar	Compute Scalar	DEFINE:([Expr1065]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1066]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1067]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1068]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END)	[Expr1065]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1066]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1067]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1068]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END	177541	0	0,0177541	71	1,993368	[af].[PairID], [af].[CandleDateTime], [Expr1065], [Expr1066], [Expr1067], [Expr1068]	NULL	PLAN_ROW	0	1
161437	1	                                                    |                        |--Index Scan(OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlatAsk1M_PairdID_CandleDateTime] AS [af]), ORDERED FORWARD)	15	115	114	Index Scan	Index Scan	OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlatAsk1M_PairdID_CandleDateTime] AS [af]), ORDERED FORWARD	[af].[PairID], [af].[BrokerServerID], [af].[CandleDateTime], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	177541	1,780162	0,1954521	78	1,975614	[af].[PairID], [af].[BrokerServerID], [af].[CandleDateTime], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	NULL	PLAN_ROW	0	1
482	3333	                                                    |--Table Spool	15	136	11	Table Spool	Lazy Spool	NULL	NULL	2,747629	0,01	0,0001008946	59	229,6738	[Expr1106], [Expr1107], [Expr1108], [Expr1109]	NULL	PLAN_ROW	0	2285238
0	0	                                                         |--Compute Scalar(DEFINE:([Expr1106]=[Union1098], [Expr1107]=[Union1099], [Expr1108]=[Union1100], [Expr1109]=[Union1101]))	15	137	136	Compute Scalar	Compute Scalar	DEFINE:([Expr1106]=[Union1098], [Expr1107]=[Union1099], [Expr1108]=[Union1100], [Expr1109]=[Union1101])	[Expr1106]=[Union1098], [Expr1107]=[Union1099], [Expr1108]=[Union1100], [Expr1109]=[Union1101]	2,747629	0	1E-07	59	0,009859461	[Expr1106], [Expr1107], [Expr1108], [Expr1109]	NULL	PLAN_ROW	0	1
157	1803	                                                              |--Nested Loops(Inner Join, OUTER REFERENCES:([p].[PairID]))	15	138	137	Nested Loops	Inner Join	OUTER REFERENCES:([p].[PairID])	NULL	1	0	8,36E-06	59	0,009859361	[Union1098], [Union1099], [Union1100], [Union1101]	NULL	PLAN_ROW	0	1
974	1803	                                                                   |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=[Expr1014]+right([Expr1015],(3))) ORDERED FORWARD)	15	139	138	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConPairs].[idx_eConPairs_Symbol] AS [p]), SEEK:([p].[Symbol]=[Expr1014]+right([Expr1015],(3))) ORDERED FORWARD	[p].[PairID]	1	0,003125	0,0001581	11	0,0032831	[p].[PairID]	NULL	PLAN_ROW	0	1
157	974	                                                                   |--Concatenation	15	140	138	Concatenation	Concatenation	NULL	[Union1098] = ([Expr1085], [Expr1092]), [Union1099] = ([Expr1086], [Expr1093]), [Union1100] = ([Expr1087], [Expr1094]), [Union1101] = ([Expr1088], [Expr1095])	2	0	2E-07	59	0,006567901	[Union1098], [Union1099], [Union1100], [Union1101]	NULL	PLAN_ROW	0	1
0	0	                                                                        |--Compute Scalar(DEFINE:([Expr1085]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1086]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1087]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1088]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END))	15	141	140	Compute Scalar	Compute Scalar	DEFINE:([Expr1085]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1086]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1087]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1088]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END)	[Expr1085]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskHigh] as [a].[AskHigh],0) END, [Expr1086]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[AskLow] as [a].[AskLow],0) END, [Expr1087]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidHigh] as [a].[BidHigh],0) END, [Expr1088]=CASE WHEN [razor_feeds].[dbo].[eConCandles1M].[BrokerServerID] as [a].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConCandles1M].[AskClose] as [a].[AskClose]+[razor_feeds].[dbo].[eConCandles1M].[BidClose] as [a].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConCandles1M].[BidLow] as [a].[BidLow],0) END	1	0	1E-07	59	0,0032832	[Expr1085], [Expr1086], [Expr1087], [Expr1088]	NULL	PLAN_ROW	0	1
157	974	                                                                        |    |--Clustered Index Seek(OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=#Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD)	15	142	141	Clustered Index Seek	Clustered Index Seek	OBJECT:([razor_feeds].[dbo].[eConCandles1M].[idx_eConCandles1M_CandleDateTime_PairID] AS [a]), SEEK:([a].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID] AND [a].[CandleDateTime]=#Ranges.[EndDate] as [r].[EndDate]) ORDERED FORWARD	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	1	0,003125	0,0001581	65	0,0032831	[a].[BrokerServerID], [a].[AskHigh], [a].[AskLow], [a].[AskClose], [a].[BidHigh], [a].[BidLow], [a].[BidClose]	NULL	PLAN_ROW	0	1
0	0	                                                                        |--Compute Scalar(DEFINE:([Expr1092]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1093]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1094]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1095]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END))	15	152	140	Compute Scalar	Compute Scalar	DEFINE:([Expr1092]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1093]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1094]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1095]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END)	[Expr1092]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskHigh] as [af].[AskHigh],0) END, [Expr1093]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[AskLow] as [af].[AskLow],0) END, [Expr1094]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidHigh] as [af].[BidHigh],0) END, [Expr1095]=CASE WHEN [razor_feeds].[dbo].[eConQuotesFlat1M].[BrokerServerID] as [af].[BrokerServerID] IS NULL THEN ([razor_feeds].[dbo].[eConQuotesFlat1M].[AskClose] as [af].[AskClose]+[razor_feeds].[dbo].[eConQuotesFlat1M].[BidClose] as [af].[BidClose])/(2.) ELSE CONVERT_IMPLICIT(decimal(21,7),[razor_feeds].[dbo].[eConQuotesFlat1M].[BidLow] as [af].[BidLow],0) END	1	0	2,084084E-07	59	0,003284501	[Expr1092], [Expr1093], [Expr1094], [Expr1095]	NULL	PLAN_ROW	0	1
0	974	                                                                             |--Index Seek(OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=#Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD)	15	153	152	Index Seek	Index Seek	OBJECT:([razor_feeds].[dbo].[eConQuotesFlat1M].[idx_eConQuotesFlat1M_CandleDateTime] AS [af]), SEEK:([af].[CandleDateTime]=#Ranges.[EndDate] as [r].[EndDate] AND [af].[PairID]=[razor_feeds].[dbo].[eConPairs].[PairID] as [p].[PairID]) ORDERED FORWARD	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	2,084084	0,003125	0,0001592925	65	0,003284293	[af].[BrokerServerID], [af].[AskHigh], [af].[AskLow], [af].[AskClose], [af].[BidHigh], [af].[BidLow], [af].[BidClose]	NULL	PLAN_ROW	0	1

Мистер Хенки,
Нет, все одинаково. В процедуре реплэйсил @Ranges на #Ranges и правил declare на create table. Запостил сюда именно из-за того, что мне не понятно, почему сервер выбирает из таблиц настолько разное количество данных. Неужели в описанной мной ситуации такого не может быть в принципе, и такое возможно только на разных данных?
8 фев 13, 16:51    [13899059]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
Да, самое главное забыл. Версия сервера:
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2550.0 (X64)
Jun 11 2012 16:41:53
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
8 фев 13, 16:53    [13899072]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Kanadec
Member

Откуда: Moscow
Сообщений: 43
А что будет если проапдейтить статистики в текущей базе?
DBCC updateusage(0) with count_rows, no_infomsgs
8 фев 13, 16:54    [13899077]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
Kanadec
А что будет если проапдейтить статистики в текущей базе?
DBCC updateusage(0) with count_rows, no_infomsgs

Без изменений
8 фев 13, 17:06    [13899173]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Мистер Хенки
Member

Откуда: канализация
Сообщений: 6615
я понял, в первом случае при loop join
проталкиваются q.Symbol = st.Item, q1.Symbol = st.Item1, q2.Symbol = st.Item2 для поиска непосредственно в dbo.eConPairs по полю Symbol. Оно очень селективно, поэтому мы в итоге делаем loop join с маленьким количеством записей
Во втором случае при hash соединении естественно это условие не проталкивается в выборку из dbo.eConPairs и потому приходиться джоинить с огромным количеством строк. Может если явно указать тип соединения loop join для
LEFT JOIN Quotes as q
			ON q.Symbol = st.Item AND q.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q1
			ON q1.Symbol = st.Item1 AND q1.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q2
			ON q2.Symbol = st.Item2 AND q2.CandleDateTime = st.EndDate

то и планы получатся похожими
8 фев 13, 17:38    [13899393]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Kanadec
Member

Откуда: Moscow
Сообщений: 43
Мистер Хенки,

непонятна ситуация почему план сильно ухудшается, не смотря на то, что по временной таблице есть статистика. Если б план ухудшался с табличной переменной - это одно, а тут совсем противоположное.
8 фев 13, 17:45    [13899427]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Мистер Хенки
Member

Откуда: канализация
Сообщений: 6615
Мистер Хенки
я понял, в первом случае при loop join
проталкиваются q.Symbol = st.Item, q1.Symbol = st.Item1, q2.Symbol = st.Item2 для поиска непосредственно в dbo.eConPairs по полю Symbol. Оно очень селективно, поэтому мы в итоге делаем loop join с маленьким количеством записей
Во втором случае при hash соединении естественно это условие не проталкивается в выборку из dbo.eConPairs и потому приходиться джоинить с огромным количеством строк. Может если явно указать тип соединения loop join для
LEFT JOIN Quotes as q
			ON q.Symbol = st.Item AND q.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q1
			ON q1.Symbol = st.Item1 AND q1.CandleDateTime = st.EndDate
		LEFT JOIN Quotes as q2
			ON q2.Symbol = st.Item2 AND q2.CandleDateTime = st.EndDate

то и планы получатся похожими

точнее не совсем так селективно условие на выборку dbo.eConQuotesFlat1M и dbo.eConCandles1M по дате CandleDateTime. Но сути не меняет, имхо. Кстати в случае с табличной переменной выборка плана запроса была закончена по таймауту. Видимо сложный запрос и оптимизатор ошибается в выборе стратегии. Ну может, кто более опытный подскажет почему, а то интересно очень.
8 фев 13, 17:54    [13899470]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
Мистер Хенки,

C хинтами и небольшими изменениями в порядке джойнов (впрочем, и без них) запрос работает гораздо быстрее чем без, но все равно не так быстро, как с табличной переменной. Ну а уж стоимость плана - просто песня: 1211. И это при отсутствии параллелизма.
В целом, вопросы остается прежними:
1. Почему сервер в нормальной ситуации, при наличии статистики составляет плохой план?
1.1. И при этом при отсутствии статистики создает хороший! Почему?

К сообщению приложен файл (план с хинтами.7z - 11Kb) cкачать
8 фев 13, 18:09    [13899533]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Ennor Tiegael
Member

Откуда:
Сообщений: 3393
AnaceH,

1. На временных таблицах можно создавать PK, unique и обычные индексы. Почему не пользуетесь? При этом на табличной переменной у вас что-то объявляется.
2. Прежде чем спрашивать "почему SQL Server не использует статистику на временных таблицах", стоит сначала убедиться, что она там адекватна действительности. Инструкций update statistics я у вас, опять-таки, не нашел.
8 фев 13, 19:05    [13899768]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Mind
Member

Откуда: Лучший город на Земле
Сообщений: 2322
Ennor Tiegael
AnaceH,

1. На временных таблицах можно создавать PK, unique и обычные индексы. Почему не пользуетесь? При этом на табличной переменной у вас что-то объявляется.
Обычно толку от этого абсолютно никакого. Что даст индекс или PK на таблице если из нее выбираются все строки? Все равно самый оптимальный способ доступа это скан. Ну и нафига нужны эти индексы?
Ennor Tiegael
2. Прежде чем спрашивать "почему SQL Server не использует статистику на временных таблицах", стоит сначала убедиться, что она там адекватна действительности. Инструкций update statistics я у вас, опять-таки, не нашел.
Какой смысл обновлять статистику на временной таблице? Она и так будет автоматически обновлена при первом обращении.
Возможно есть смысл запретить создание/обновление статистики на этой таблице, тогда план будет такой же как и для табличной переменной. Но это уж совсем костыль.
8 фев 13, 23:56    [13900924]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Mind
Member

Откуда: Лучший город на Земле
Сообщений: 2322
Мистер Хенки
почему то
в
LEFT JOIN Quotes as q
			...

В обоих планах как то очень разное количество записей джойнится, хотя вроде порядо соединения таблиц похож очень, только тип соединения разный. Есть такое ощущение, что на разных данных выполнили разные запросы, а потом сравнивают их скорость выполнения
Не, Мистер, вы далеко полезли. ТС правильно заметил, все проблемы начинаются после Hash Match, там где вместо реальных 3 тыщ строк оценка показывает пол миллиона. Естественно весь остальной план перекраивается на merge/hash/scan etc.

А кстати кто нибудь заметил, что Estimated Rows из табличной переменной = 1055 строк, хотя обычно сервер считает что там всего одна строка. Скорее всего это произошло потому, что все это запускается в хранимке + есть временные таблицы, из-за чего происходит перекомпиляция и берутся реальные значения. А если бы сервер оценил количество строк = 1, то тут бы планы вообще могли поехать.
9 фев 13, 01:15    [13901366]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Mind
Member

Откуда: Лучший город на Земле
Сообщений: 2322
AnaceH
1. Почему сервер в нормальной ситуации, при наличии статистики составляет плохой план?
1.1. И при этом при отсутствии статистики создает хороший! Почему?
Потому что отсутствие статистики может быть лучше, чем плохая статистика.
А скорее всего тут дело в том как сервер эту статистику использует. И похоже получается это у него плохо из-за вот этого условия:

ON (
      (
          t.OpenTimeUtc BETWEEN r.StartDate AND r.EndDate 
        AND 
          (
              t.CloseTimeUtc > r.EndDate 
            OR 
              t.CloseTimeUtc IS NULL
          )
      )
   OR 
     (
          t.OpenTimeUtc < r.StartDate 
        AND 
          (
              t.CloseTimeUtc > r.EndDate 
            OR 
              t.CloseTimeUtc IS NULL
          )
     )
   )
  and r.StatsAccountID = t.StatsAccountID
Часто сервер не может просто по AND нормально посчитать кардиналити (ввиду такой мат. модели), а тут еще такое количество OR.

+ если нигде не ошибся
-- то можно упростить так:
ON (
      (
          t.OpenTimeUtc BETWEEN r.StartDate AND r.EndDate
        OR
          t.OpenTimeUtc < r.StartDate
      )
      AND 
      (
          t.CloseTimeUtc > r.EndDate 
        OR 
          t.CloseTimeUtc IS NULL
      )
   )
  and r.StatsAccountID = t.StatsAccountID	

-- потом вот так:

ON (
      t.OpenTimeUtc <= r.EndDate
      AND 
      (
          t.CloseTimeUtc > r.EndDate 
        OR 
          t.CloseTimeUtc IS NULL
      )
   )
  and r.StatsAccountID = t.StatsAccountID		
	
-- и вот так:
ON (
      (t.OpenTimeUtc <= r.EndDate AND t.CloseTimeUtc > r.EndDate)
      OR
      (t.OpenTimeUtc <= r.EndDate AND t.CloseTimeUtc IS NULL)
   )
  and r.StatsAccountID = t.StatsAccountID			

Не знаю насколько легче станет серверу, но попробуйте. Как вариант еще попробовать разбить OR на UNION ALL.
Ну и последний вариант, кинуть подзапрос "AS st" во временную таблицу, и уже потом её использовать. Тогда оценки 100% будут нормальными.
9 фев 13, 01:28    [13901418]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Мистер Хенки
Member

Откуда: канализация
Сообщений: 6615
AnaceH
Мистер Хенки,

C хинтами и небольшими изменениями в порядке джойнов (впрочем, и без них) запрос работает гораздо быстрее чем без, но все равно не так быстро, как с табличной переменной. Ну а уж стоимость плана - просто песня: 1211. И это при отсутствии параллелизма.
В целом, вопросы остается прежними:
1. Почему сервер в нормальной ситуации, при наличии статистики составляет плохой план?
1.1. И при этом при отсутствии статистики создает хороший! Почему?

Вот тут вот
FROM @Ranges AS r
			LEFT JOIN 

если написать подсказку Hash join, то мне сдается что план с хинтами станет идентичным плану с табличной переменной. Почему ошибается, я не знаю, скорее всего, потому что запрос сложный, слишком много вариантов выполнения. В плане с табличной переменной оптимизатор вышел по таймауту, т.е. теоретически он выбрал не самый "оптимальный" план. Если хотите как-то побыстрее сделать запрос, то наверное его стоит упростить.
11 фев 13, 10:03    [13906926]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
AnaceH
Member

Откуда:
Сообщений: 109
Мистер Хенки
Вот тут вот
FROM @Ranges AS r
			LEFT JOIN 

если написать подсказку Hash join, то мне сдается что план с хинтами станет идентичным плану с табличной переменной.

Не станет, попробовал сразу же. Лупы при лефт джойнах Quotes делают план и то более похожим на требуемый.
Mind
Ну и последний вариант, кинуть подзапрос "AS st" во временную таблицу, и уже потом её использовать. Тогда оценки 100% будут нормальными.

Оценка действительно стала точнее, но почему-то сервера тянет из eConCandles строк больше, чем ему требуется. Например, в запросе с табличной переменной и подзапросом в первый раз из этой таблицы извлекается 307 строк, а для нового запроса - 889. Все равно мне не понятно почему такое происходит... Зато запрос стал работать быстрее чем с табличной переменной, спасибо. Кроме того, спасибо за t.OpenTimeUtc <= r.EndDate, действительно, косяк. План в аттаче.

К сообщению приложен файл (подзапрос во временную.7z - 9Kb) cкачать
11 фев 13, 11:14    [13907287]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Гость333
Member

Откуда:
Сообщений: 3683
Mind
отсутствие статистики может быть лучше, чем плохая статистика.
А скорее всего тут дело в том как сервер эту статистику использует. И похоже получается это у него плохо из-за вот этого условия:

+1. Вот здесь я приводил простой пример, когда самая актуальная статистика даёт совершенно неправильные значения cardinality при AND-условии со специфическим распределением данных (а оптимизатор предполагает некое "среднестатистически-равномерное" распределение).

Поэтому в подобных ситуациях не стоит удивляться самым причудливым планам запроса. Если получается упростить или переписать запрос — упрощаем, переписываем. Не получается — хинтуем.
11 фев 13, 11:22    [13907339]     Ответить | Цитировать Сообщить модератору
 Re: Изменение плана при @ -> #  [new]
Mind
Member

Откуда: Лучший город на Земле
Сообщений: 2322
AnaceH
Оценка действительно стала точнее, но почему-то сервера тянет из eConCandles строк больше, чем ему требуется. Например, в запросе с табличной переменной и подзапросом в первый раз из этой таблицы извлекается 307 строк, а для нового запроса - 889.
Я не вижу в этом проблемы.
13 фев 13, 03:20    [13917671]     Ответить | Цитировать Сообщить модератору
Все форумы / Microsoft SQL Server Ответить