August 11, 2015 at 3:43 am
mohan_padekal (8/11/2015)
Getting this error while execute the scriptMsg 207, Level 16, State 1, Line 24
Invalid column name 'last_rows'.
Just remove the last_rows from the select clause then run it. That column was added to the DMV in 2012 I think.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 11, 2015 at 3:44 am
Grant Fritchey (8/11/2015)
mohan_padekal (8/11/2015)
First i updated Statistics of DataMaster table then try to execute the script that time getting errorUpdating statistics won't change the names of columns. Have you made other changes to the script or your tables?
It's Eric's query that's throwing the missing column error, DMV didn't have that particular column in SQL 2008.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 11, 2015 at 4:06 am
Earlier we processed some testing and we deleted old data from that table.We never run update statistics after DB creation. Is it required to update table statistics.
August 11, 2015 at 4:37 am
Can anyone tell me how to post attachment files.
August 11, 2015 at 5:03 am
As mentioned i made changes like this in sproc
CREATE PROCEDURE [dbo].[FetchDocumentID]
(@i_UserId int,
@i_ProjectId int)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Error INT = 0
, @ErrorLine INT
, @ErrorDesc NVARCHAR(1000)
, @Message NVARCHAR(1000)
, @ProcName NVARCHAR(128) = N'Project.dbo.FetchDocumentID.procedure.sql'
, @VALUES VARCHAR(128)
, @UserDetailId BIGINT
, @RoleName VARCHAR(150)
BEGIN TRY
CREATE TAble #Document (Id INT IDENTITY(1,1) PRIMARY KEY
,FieldId INT
, DocumentID INT
, Rejected INT )
IF NOT EXISTS(SELECT UA.AccessId
FROM dbo.UserAccess UA
WHERE UA.ProjectMasterId = @i_ProjectId
AND UA.AccessId = 4
)
BEGIN
INSERT #Document (DocumentID,Rejected )
SELECT TOP 1 [DM].[DocumentId],1
FROM [dbo].[DataMaster] DM WITH(NOLOCK)
LEFT JOIN [dbo].[DocumentMaster] DC WITH(NOLOCK)
ON [DM].[DocumentId] = [DC].[DocumentMasterId]
WHERE [DM].[IsCoded] = 1
AND [DM].[IsRejected]=1
AND [DM].CoderId = @i_UserId
AND [DC].[ProjectId] = @i_ProjectId
AND (([DC].[IsLocked] = 1 and [DC].[Status] = @i_UserId)
OR ([DC].[IsLocked] = 0 AND [DC].[IsChecked] = 1 ))
GROUP BY [DM].[DocumentId]
ORDER BY [DM].[DocumentId]
END
IF NOT EXISTS(SELECT * FROM #Document)
BEGIN
INSERT #Document (FieldId
,DocumentID)
SELECT A.FieldId
, B.DocumentMasterId
FROM dbo.UserAccess A WITH(NOLOCK)
INNER JOIN dbo.DocumentMaster B WITH(NOLOCK)
ON A.ProjectMasterId = b.ProjectId
WHERE A.[UserMasterId] =@i_UserId
AND A.ProjectMasterId=@i_ProjectId
AND (B.IsLocked = 0 OR (B.IsLocked = 1 AND B.[STATUS] = @i_UserId) )
CREATE TABLE #temp1(DocID INT )
INSERT #temp1
SELECT TOP 1 A.DocumentID
FROM #Document A
-- LEFT JOIN DataMaster b
--ON a.FieldId = b.FieldId
-- AND a.DocumentID = b.DocumentId
-- WHERE b.DocumentId IS NULL
Where A.DocumentID Not IN (Select documentid from DataMaster )
GROUP BY A.DocumentID
ORDER BY a.DocumentID
if EXISTS(select * from #temp1)
Begin
UPDATE [dbo].[DocumentMaster]
SET [IsLocked] = 1
,[LockedTime] = SYSDATETIME()
,[Status] = @i_UserId
WHERE [DocumentMasterId] = (select DocID from #temp1)
End
SELECT TOP 1 A.DocumentID
, 0 AS Rejected
FROM #Document A
-- LEFT JOIN DataMaster b
--ON a.FieldId = b.FieldId
-- AND a.DocumentID = b.DocumentId
-- WHERE b.DocumentId IS NULL
Where A.DocumentID Not IN (Select documentid from DataMaster )
GROUP BY A.DocumentID
ORDER BY a.DocumentID
END
ELSE
BEGIN
UPDATE [dbo].[DocumentMaster]
SET [IsLocked] = 1
,[LockedTime] = SYSDATETIME()
,[Status] = @i_UserId
WHERE [DocumentMasterId] = (select DocumentID from #Document)
SELECT A.DocumentID,Rejected
FROM #Document A
ORDER BY A.DocumentID
END
END TRY
BEGIN CATCH
SELECT @Error = ERROR_NUMBER()
, @ErrorLine = ERROR_LINE()
, @ErrorDesc = ERROR_MESSAGE()
SET @Message = N'Application of the procedure, %s, failed at line, %d, due to error no. %d.: %s'
RAISERROR(@Message, 11, 1, @ProcName, @ErrorLine, @Error, @ErrorDesc) WITH NOWAIT
END CATCH
END_THIS:
RETURN (@Error)
END--FetchDocumentID
here the execution plan
<?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.1" Build="10.50.1600.1" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
<BatchSequence>
<Batch>
<Statements>
<StmtSimple StatementCompId="7" StatementEstRows="1" StatementId="1" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0143788" StatementText="IF NOT EXISTS(SELECT UA.AccessId FROM dbo.UserAccess UA WHERE UA.ProjectMasterId = @i_ProjectId AND UA.AccessId = 4 ) " StatementType="COND WITH QUERY" QueryHash="0xA74AB84D9722F10E" QueryPlanHash="0x4E2F22B1AC12CD98">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="160">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0143788">
<OutputList>
<ColumnReference Column="Expr1002" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1002" />
<ScalarOperator ScalarString="CASE WHEN [Expr1003] IS NULL THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1003" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0143787">
<OutputList>
<ColumnReference Column="Expr1003" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1003" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1003" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="16" EstimateCPU="0.0017135" EstimateIO="0.0112731" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="3" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0129866" TableCardinality="1415">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[PK_UserAccess]" Alias="[UA]" IndexKind="Clustered" />
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[UserAccess].[AccessId] as [UA].[AccessId]=(4) AND [SH_Semper].[dbo].[UserAccess].[ProjectMasterId] as [UA].[ProjectMasterId]=CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[UA]" Column="AccessId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(4)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[UA]" Column="ProjectMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(167)" ParameterRuntimeValue="(167)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="8" StatementEstRows="1" StatementId="2" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0279351" StatementText="INSERT #Document (DocumentID,Rejected ) SELECT TOP 1 [DM].[DocumentId],1 FROM [dbo].[DataMaster] DM WITH(NOLOCK) LEFT JOIN [dbo].[DocumentMaster] DC WITH(NOLOCK) ON [DM].[DocumentId] = [DC].[DocumentMasterId] WHERE [DM].[IsCoded] = 1 AND [DM].[IsRejected]=1 AND [DM].CoderId = @i_UserId AND [DC].[ProjectId] = @i_ProjectId AND (([DC].[IsLocked] = 1 and [DC].[Status] = @i_UserId) OR ([DC].[IsLocked] = 0 AND [DC].[IsChecked] = 1 )) GROUP BY [DM].[DocumentId] ORDER BY [DM].[DocumentId] " StatementType="INSERT" QueryHash="0x66355D87178B8DA3" QueryPlanHash="0xAC02F96AE498596B">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="40" CompileTime="15" CompileCPU="15" CompileMemory="696">
<RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Clustered Index Insert" EstimatedTotalSubtreeCost="0.0279351">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC0779CCD39E]" />
<SetPredicate>
<ScalarOperator ScalarString="[#Document].[DocumentID] = [Expr1009],[#Document].[Rejected] = [Expr1007],[#Document].[Id] = [Expr1008],[#Document].[FieldId] = NULL">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#Document]" Column="DocumentID" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Rejected" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1007" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Id" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="FieldId" />
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="19" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0179341">
<OutputList>
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[DataMaster].[DocumentId] as [DM].[DocumentId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="23" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.017934">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="getidentity((2011466540),(2),N'#Document')">
<Intrinsic FunctionName="getidentity">
<ScalarOperator>
<Const ConstValue="(2011466540)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(2)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="N'#Document'" />
</ScalarOperator>
</Intrinsic>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="19" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="3" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0179339">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
<ColumnReference Column="Expr1007" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1007" />
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="15" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="4" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0179338">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="15" EstimateCPU="0.000100015" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Distinct Sort" NodeId="5" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0179337">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="true">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="15" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Inner Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00657246">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OuterReferences>
<RelOp AvgRowSize="15" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="7" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="10750">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[IND000002]" Alias="[DM]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="IsCoded" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="IsRejected" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="CoderId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
<ScalarOperator ScalarString="[@i_UserId]">
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
<RelOp AvgRowSize="20" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="8" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="9313">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="0" ActualExecutions="0" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[PK_DocumentInfo]" Alias="[DC]" IndexKind="Clustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="DocumentMasterId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DataMaster].[DocumentId] as [DM].[DocumentId]">
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[ProjectId] as [DC].[ProjectId]=CONVERT_IMPLICIT(bigint,[@i_ProjectId],0) AND ([SH_Semper].[dbo].[DocumentMaster].[IsLocked] as [DC].[IsLocked]=(1) AND [SH_Semper].[dbo].[DocumentMaster].[Status] as [DC].[Status]=[@i_UserId] OR [SH_Semper].[dbo].[DocumentMaster].[IsLocked] as [DC].[IsLocked]=(0) AND [SH_Semper].[dbo].[DocumentMaster].[IsChecked] as [DC].[IsChecked]=(1))">
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="ProjectId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="OR">
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="IsChecked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</Sort>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(167)" ParameterRuntimeValue="(167)" />
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(43)" ParameterRuntimeValue="(43)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="10" StatementEstRows="1" StatementId="3" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="IF NOT EXISTS(SELECT * FROM #Document) " StatementType="COND WITH QUERY" QueryHash="0xAF0B76B73C0A6A78" QueryPlanHash="0xBCB0B4CCB60404A4">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="112">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1004" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1004" />
<ScalarOperator ScalarString="CASE WHEN [Expr1005] IS NULL THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1005" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1005" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1005" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="3" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07649BE137]" />
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="11" StatementEstRows="500" StatementId="4" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0330546" StatementText="INSERT #Document (FieldId ,DocumentID) SELECT A.FieldId , B.DocumentMasterId FROM dbo.UserAccess A WITH(NOLOCK) INNER JOIN dbo.DocumentMaster B WITH(NOLOCK) ON A.ProjectMasterId = b.ProjectId WHERE A.[UserMasterId] =@i_UserId AND A.ProjectMasterId=@i_ProjectId AND (B.IsLocked = 0 OR (B.IsLocked = 1 AND B.[STATUS] = @i_UserId) ) " StatementType="INSERT" QueryHash="0x07D8ED14A91048BA" QueryPlanHash="0xB6FB4F6E1BCBB47F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="32" CompileTime="3" CompileCPU="3" CompileMemory="336">
<RelOp AvgRowSize="9" EstimateCPU="0.0005" EstimateIO="0.0110788" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="500" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Clustered Index Insert" EstimatedTotalSubtreeCost="0.0330546">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC0718BB6F12]" />
<SetPredicate>
<ScalarOperator ScalarString="[#Document].[FieldId] = [Expr1008],[#Document].[DocumentID] = [Expr1009],[#Document].[Id] = [Expr1007],[#Document].[Rejected] = NULL">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#Document]" Column="FieldId" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="DocumentID" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Id" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1007" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Rejected" />
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="19" EstimateCPU="5E-05" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="500" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0214757">
<OutputList>
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[UserAccess].[FieldId] as [A].[FieldId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[DocumentMaster].[DocumentMasterId] as .[DocumentMasterId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="27" EstimateCPU="5E-05" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="500" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0214257">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
<ColumnReference Column="Expr1007" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1007" />
<ScalarOperator ScalarString="getidentity((382936736),(2),N'#Document')">
<Intrinsic FunctionName="getidentity">
<ScalarOperator>
<Const ConstValue="(382936736)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(2)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="N'#Document'" />
</ScalarOperator>
</Intrinsic>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="23" EstimateCPU="5E-05" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="500" LogicalOp="Top" NodeId="3" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0213757">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="true" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(0)">
<Const ConstValue="(0)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="23" EstimateCPU="0.00209" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="500" LogicalOp="Inner Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0213257">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<RelOp AvgRowSize="27" EstimateCPU="0.0017135" EstimateIO="0.0112731" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="5" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0129866" TableCardinality="1415">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="5" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[PK_UserAccess]" Alias="[A]" IndexKind="Clustered" />
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[UserAccess].[ProjectMasterId] as [A].[ProjectMasterId]=CONVERT_IMPLICIT(bigint,[@i_ProjectId],0) AND [SH_Semper].[dbo].[UserAccess].[UserMasterId] as [A].[UserMasterId]=[@i_UserId]">
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="ProjectMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
<RelOp AvgRowSize="20" EstimateCPU="0.000707" EstimateIO="0.00365687" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="500" LogicalOp="Index Seek" NodeId="6" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00436387" TableCardinality="9313">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="5" ActualExecutions="5" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[IND000003]" Alias="" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="ProjectId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[IsLocked] as .[IsLocked]=(0) OR [SH_Semper].[dbo].[DocumentMaster].[IsLocked] as .[IsLocked]=(1) AND [SH_Semper].[dbo].[DocumentMaster].[Status] as .[Status]=[@i_UserId]">
<Logical Operation="OR">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(167)" ParameterRuntimeValue="(167)" />
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(43)" ParameterRuntimeValue="(43)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="13" StatementEstRows="1" StatementId="5" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0829822" StatementText="INSERT #temp1 SELECT TOP 1 A.DocumentID FROM #Document A -- LEFT JOIN DataMaster b --ON a.FieldId = b.FieldId -- AND a.DocumentID = b.DocumentId -- WHERE b.DocumentId IS NULL Where A.DocumentID Not IN (Select documentid from DataMaster ) GROUP BY A.DocumentID ORDER BY a.DocumentID " StatementType="INSERT" QueryHash="0x834313FB7482F898" QueryPlanHash="0xFA148C46590C122F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="32" CompileTime="20" CompileCPU="20" CompileMemory="552">
<RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0829822">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
<SetPredicate>
<ScalarOperator ScalarString="[#temp1].[DocID] = #document.[DocumentID] as [A].[DocumentID]">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#temp1]" Column="DocID" />
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="1" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0729812">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="11" EstimateCPU="0.000560996" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="2" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0729811">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues />
<GroupBy>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</GroupBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.86336" LogicalOp="Left Anti Semi Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0729796">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="6" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false" WithOrderedPrefetch="true">
<OuterReferences>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1009" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Left Anti Semi Join" NodeId="5" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0687556">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1811" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID] IS NULL">
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
<RelOp AvgRowSize="11" EstimateCPU="0.0426352" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Sort" NodeId="6" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0650311">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="1811" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="false">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0028245" EstimateIO="0.00831019" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2425" LogicalOp="Clustered Index Scan" NodeId="7" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0111347" TableCardinality="2425">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC0779CCD39E]" Alias="[A]" />
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Top" NodeId="8" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00377623">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1811" ActualEndOfScans="1811" ActualExecutions="1811" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.0119035" EstimateIO="0.0802405" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="9" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00377552" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1811" ActualEndOfScans="0" ActualExecutions="1811" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[PK_DataMaster]" IndexKind="Clustered" />
</IndexScan>
</RelOp>
</Top>
</RelOp>
</NestedLoops>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001001" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="5.59009" EstimateRows="1" LogicalOp="Lazy Spool" NodeId="12" Parallel="false" PhysicalOp="Row Count Spool" EstimatedTotalSubtreeCost="0.00426214">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="363" ActualRewinds="1448" ActualRows="1805" ActualEndOfScans="6" ActualExecutions="1811" />
</RunTimeInformation>
<RowCountSpool>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="14" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00347861">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="361" ActualEndOfScans="2" ActualExecutions="363" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.00015993" EstimateIO="0.003125" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="15" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00347838" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="361" ActualEndOfScans="2" ActualExecutions="363" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[IND000001]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Column="DocumentId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID]">
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</Top>
</RelOp>
</RowCountSpool>
</RelOp>
</NestedLoops>
</RelOp>
</StreamAggregate>
</RelOp>
</Top>
</RelOp>
</Update>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="14" StatementEstRows="1" StatementId="6" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="if EXISTS(select * from #temp1) " StatementType="COND WITH QUERY" QueryHash="0x1A42CB848023B8D5" QueryPlanHash="0xD64ABA727B7D8D4F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="104">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1005" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
<ScalarOperator ScalarString="CASE WHEN [Expr1006] THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1006" />
</Identifier>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1006" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1006" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1006" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Table Scan" NodeId="3" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<TableScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
</TableScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="15" StatementEstRows="1" StatementId="7" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0265743" StatementText="UPDATE [dbo].[DocumentMaster] SET [IsLocked] = 1 ,[LockedTime] = SYSDATETIME() ,[Status] = @i_UserId WHERE [DocumentMasterId] = (select DocID from #temp1) " StatementType="UPDATE" QueryHash="0x2254A6C248573DBF" QueryPlanHash="0x11E6E959F4D26F5C">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="40" CompileTime="5" CompileCPU="5" CompileMemory="408">
<RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0.02" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Update" NodeId="1" Parallel="false" PhysicalOp="Clustered Index Update" EstimatedTotalSubtreeCost="0.0265743">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[PK_DocumentInfo]" IndexKind="Clustered" />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[IND000003]" IndexKind="NonClustered" />
<SetPredicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[IsLocked] = [Expr1008],[SH_Semper].[dbo].[DocumentMaster].[LockedTime] = [Expr1009],[SH_Semper].[dbo].[DocumentMaster].[Status] = [@i_UserId]">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="LockedTime" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="28" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657226">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
<ColumnReference Column="Expr1025" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1025" />
<ScalarOperator ScalarString="[Expr1025]">
<Identifier>
<ColumnReference Column="Expr1025" />
</Identifier>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="28" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="3" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657226">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
<ColumnReference Column="Expr1025" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1025" />
<ScalarOperator ScalarString="CASE WHEN [Expr1013] AND [Expr1015] THEN (0) ELSE (1) END">
<IF>
<Condition>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1013" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1015" />
</Identifier>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="24" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="4" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657216">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
<ColumnReference Column="Expr1013" />
<ColumnReference Column="Expr1015" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(datetime,sysdatetime(),0)">
<Identifier>
<ColumnReference Column="ConstExpr1016">
<ScalarOperator>
<Convert DataType="datetime" Style="0" Implicit="true">
<ScalarOperator>
<Intrinsic FunctionName="sysdatetime" />
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1015" />
<ScalarOperator ScalarString="CASE WHEN [SH_Semper].[dbo].[DocumentMaster].[Status] = [@i_UserId] THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="BINARY IS">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="20" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657206">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
<ColumnReference Column="Expr1013" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1013" />
<ScalarOperator ScalarString="CASE WHEN [SH_Semper].[dbo].[DocumentMaster].[IsLocked] = (1) THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="BINARY IS">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="20" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Inner Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00657196">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Column="Expr1018" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="4.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Assert" NodeId="7" Parallel="false" PhysicalOp="Assert" EstimatedTotalSubtreeCost="0.00328468">
<OutputList>
<ColumnReference Column="Expr1018" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Assert StartupExpression="false">
<RelOp AvgRowSize="19" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="8" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">
<OutputList>
<ColumnReference Column="Expr1017" />
<ColumnReference Column="Expr1018" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1017" />
<ScalarOperator ScalarString="Count(*)">
<Aggregate AggType="countstar" Distinct="false" />
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1018" />
<ScalarOperator ScalarString="ANY([#temp1].[DocID])">
<Aggregate AggType="ANY" Distinct="false">
<ScalarOperator>
<Identifier>
<ColumnReference Table="[#temp1]" Column="DocID" />
</Identifier>
</ScalarOperator>
</Aggregate>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="11" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Table Scan" NodeId="9" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1">
<OutputList>
<ColumnReference Table="[#temp1]" Column="DocID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<TableScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="[#temp1]" Column="DocID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
</TableScan>
</RelOp>
</StreamAggregate>
</RelOp>
<Predicate>
<ScalarOperator ScalarString="CASE WHEN [Expr1017]>(1) THEN (0) ELSE NULL END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="GT">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1017" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</Predicate>
</Assert>
</RelOp>
<RelOp AvgRowSize="20" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="14" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="9313">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
</DefinedValue>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
</DefinedValue>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[PK_DocumentInfo]" IndexKind="Clustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="[Expr1018]">
<Identifier>
<ColumnReference Column="Expr1018" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(43)" ParameterRuntimeValue="(43)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="17" StatementEstRows="1" StatementId="8" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0729813" StatementText="SELECT TOP 1 A.DocumentID , 0 AS Rejected FROM #Document A -- LEFT JOIN DataMaster b --ON a.FieldId = b.FieldId -- AND a.DocumentID = b.DocumentId -- WHERE b.DocumentId IS NULL Where A.DocumentID Not IN (Select documentid from DataMaster ) GROUP BY A.DocumentID ORDER BY a.DocumentID " StatementType="SELECT" QueryHash="0x5F38275189DB2B2D" QueryPlanHash="0xA3D478916873EB4D">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="32" CompileTime="17" CompileCPU="17" CompileMemory="528">
<RelOp AvgRowSize="15" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0729813">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1005" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
<ScalarOperator ScalarString="(0)">
<Const ConstValue="(0)" />
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="1" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0729812">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="11" EstimateCPU="0.000560996" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="2" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0729811">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues />
<GroupBy>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</GroupBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.86336" LogicalOp="Left Anti Semi Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0729796">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="6" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false" WithOrderedPrefetch="true">
<OuterReferences>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1006" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Left Anti Semi Join" NodeId="5" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0687556">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1811" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID] IS NULL">
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
<RelOp AvgRowSize="11" EstimateCPU="0.0426352" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Sort" NodeId="6" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0650311">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="1811" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="false">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0028245" EstimateIO="0.00831019" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2425" LogicalOp="Clustered Index Scan" NodeId="7" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0111347" TableCardinality="2425">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2425" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC0779CCD39E]" Alias="[A]" />
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Top" NodeId="8" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00377623">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1811" ActualEndOfScans="1811" ActualExecutions="1811" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.0119035" EstimateIO="0.0802405" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="9" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00377552" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1811" ActualEndOfScans="0" ActualExecutions="1811" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[PK_DataMaster]" IndexKind="Clustered" />
</IndexScan>
</RelOp>
</Top>
</RelOp>
</NestedLoops>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001001" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="5.59009" EstimateRows="1" LogicalOp="Lazy Spool" NodeId="12" Parallel="false" PhysicalOp="Row Count Spool" EstimatedTotalSubtreeCost="0.00426214">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="363" ActualRewinds="1448" ActualRows="1805" ActualEndOfScans="6" ActualExecutions="1811" />
</RunTimeInformation>
<RowCountSpool>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="14" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00347861">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="361" ActualEndOfScans="2" ActualExecutions="363" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.00015993" EstimateIO="0.003125" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="15" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00347838" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="361" ActualEndOfScans="2" ActualExecutions="363" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[IND000001]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Column="DocumentId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID]">
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</Top>
</RelOp>
</RowCountSpool>
</RelOp>
</NestedLoops>
</RelOp>
</StreamAggregate>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
</BatchSequence>
</ShowPlanXML>
After made this change seeing some improvement in application
August 11, 2015 at 7:12 am
GilaMonster (8/11/2015)
Grant Fritchey (8/11/2015)
mohan_padekal (8/11/2015)
First i updated Statistics of DataMaster table then try to execute the script that time getting errorUpdating statistics won't change the names of columns. Have you made other changes to the script or your tables?
It's Eric's query that's throwing the missing column error, DMV didn't have that particular column in SQL 2008.
I copy and pasted my query from above into SSMS and confirmed it works on a 2008 R2 dev instance with no problems. Here is my exact version.
SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
August 11, 2015 at 7:19 am
Eric M Russell (8/11/2015)
GilaMonster (8/11/2015)
Grant Fritchey (8/11/2015)
mohan_padekal (8/11/2015)
First i updated Statistics of DataMaster table then try to execute the script that time getting errorUpdating statistics won't change the names of columns. Have you made other changes to the script or your tables?
It's Eric's query that's throwing the missing column error, DMV didn't have that particular column in SQL 2008.
I copy and pasted my query from above into SSMS and confirmed it works on a 2008 R2 dev instance with no problems. Here is my exact version.
SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
When was that column added then? Can't recall what version it was added in, I don't think it was there in 2005, but could be mistaken (and I have nothing lower than 2012 to test on)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 11, 2015 at 7:57 am
GilaMonster (8/11/2015)
Eric M Russell (8/11/2015)
GilaMonster (8/11/2015)
Grant Fritchey (8/11/2015)
mohan_padekal (8/11/2015)
First i updated Statistics of DataMaster table then try to execute the script that time getting errorUpdating statistics won't change the names of columns. Have you made other changes to the script or your tables?
It's Eric's query that's throwing the missing column error, DMV didn't have that particular column in SQL 2008.
I copy and pasted my query from above into SSMS and confirmed it works on a 2008 R2 dev instance with no problems. Here is my exact version.
SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
When was that column added then? Can't recall what version it was added in, I don't think it was there in 2005, but could be mistaken (and I have nothing lower than 2012 to test on)
Looking on MSDN, I'm only seeing [last_rows] documented starting at 2008 R2.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
August 12, 2015 at 2:32 am
August 13, 2015 at 7:53 am
We made change in SP like this and tested in two locations 1st location with 15 - 20 user and 2nd location with 50- 60 user.
1st location we not face slow issue now but in 2nd location again observing same slow issue.
Here is my modified sp
CREATE PROCEDURE [dbo].[FetchDocumentID]
(@i_UserId int,
@i_ProjectId int)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Error INT = 0
, @ErrorLine INT
, @ErrorDesc NVARCHAR(1000)
, @Message NVARCHAR(1000)
, @ProcName NVARCHAR(128) = N'Project.dbo.FetchDocumentID.procedure.sql'
, @VALUES VARCHAR(128)
, @UserDetailId BIGINT
, @RoleName VARCHAR(150)
BEGIN TRY
CREATE TAble #Document (Id INT IDENTITY(1,1) PRIMARY KEY
,FieldId INT
, DocumentID INT
, Rejected INT )
IF NOT EXISTS(SELECT UA.AccessId
FROM dbo.UserAccess UA
WHERE UA.ProjectMasterId = @i_ProjectId
AND UA.AccessId = 4
)
BEGIN
INSERT #Document (DocumentID,Rejected )
SELECT TOP 1 [DM].[DocumentId],1
FROM [dbo].[DataMaster] DM WITH(NOLOCK)
LEFT JOIN [dbo].[DocumentMaster] DC WITH(NOLOCK)
ON [DM].[DocumentId] = [DC].[DocumentMasterId]
WHERE [DM].[IsCoded] = 1
AND [DM].[IsRejected]=1
AND [DM].CoderId = @i_UserId
AND [DC].[ProjectId] = @i_ProjectId
AND (([DC].[IsLocked] = 1 and [DC].[Status] = @i_UserId)
OR ([DC].[IsLocked] = 0 AND [DC].[IsChecked] = 1 ))
GROUP BY [DM].[DocumentId]
ORDER BY [DM].[DocumentId]
END
IF NOT EXISTS(SELECT * FROM #Document)
BEGIN
INSERT #Document (FieldId
,DocumentID)
SELECT A.FieldId
, B.DocumentMasterId
FROM dbo.UserAccess A WITH(NOLOCK)
INNER JOIN dbo.DocumentMaster B WITH(NOLOCK)
ON A.ProjectMasterId = b.ProjectId
WHERE A.[UserMasterId] =@i_UserId
AND A.ProjectMasterId=@i_ProjectId
AND (B.IsLocked = 0 OR (B.IsLocked = 1 AND B.[STATUS] = @i_UserId) )
CREATE TABLE #temp1(DocID INT )
INSERT #temp1
SELECT TOP 1 A.DocumentID
FROM #Document A
-- LEFT JOIN DataMaster b
--ON a.FieldId = b.FieldId
-- AND a.DocumentID = b.DocumentId
-- WHERE b.DocumentId IS NULL
Where A.DocumentID Not IN (Select documentid from DataMaster )
GROUP BY A.DocumentID
ORDER BY a.DocumentID
if EXISTS(select * from #temp1)
Begin
UPDATE [dbo].[DocumentMaster]
SET [IsLocked] = 1
,[LockedTime] = SYSDATETIME()
,[Status] = @i_UserId
WHERE [DocumentMasterId] = (select DocID from #temp1)
End
SELECT TOP 1 A.DocumentID
, 0 AS Rejected
FROM #Document A
-- LEFT JOIN DataMaster b
--ON a.FieldId = b.FieldId
-- AND a.DocumentID = b.DocumentId
-- WHERE b.DocumentId IS NULL
Where A.DocumentID Not IN (Select documentid from DataMaster )
GROUP BY A.DocumentID
ORDER BY a.DocumentID
END
ELSE
BEGIN
UPDATE [dbo].[DocumentMaster]
SET [IsLocked] = 1
,[LockedTime] = SYSDATETIME()
,[Status] = @i_UserId
WHERE [DocumentMasterId] = (select DocumentID from #Document)
SELECT A.DocumentID,Rejected
FROM #Document A
ORDER BY A.DocumentID
END
END TRY
BEGIN CATCH
SELECT @Error = ERROR_NUMBER()
, @ErrorLine = ERROR_LINE()
, @ErrorDesc = ERROR_MESSAGE()
SET @Message = N'Application of the procedure, %s, failed at line, %d, due to error no. %d.: %s'
RAISERROR(@Message, 11, 1, @ProcName, @ErrorLine, @Error, @ErrorDesc) WITH NOWAIT
END CATCH
END_THIS:
RETURN (@Error)
END--FetchDocumentID
Here the 1st location Execution plan
<?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.1" Build="10.50.1600.1" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
<BatchSequence>
<Batch>
<Statements>
<StmtSimple StatementCompId="7" StatementEstRows="1" StatementId="1" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00827512" StatementText="IF NOT EXISTS(SELECT UA.AccessId FROM dbo.UserAccess UA WHERE UA.ProjectMasterId = @i_ProjectId AND UA.AccessId = 4 ) " StatementType="COND WITH QUERY" QueryHash="0xA74AB84D9722F10E" QueryPlanHash="0x4E2F22B1AC12CD98">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="168">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00827512">
<OutputList>
<ColumnReference Column="Expr1002" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1002" />
<ScalarOperator ScalarString="CASE WHEN [Expr1003] IS NULL THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1003" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00827502">
<OutputList>
<ColumnReference Column="Expr1003" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1003" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1003" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="16" EstimateCPU="0.0017135" EstimateIO="0.0120139" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="3" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00768471" TableCardinality="1415">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[PK_UserAccess]" Alias="[UA]" IndexKind="Clustered" />
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[UserAccess].[AccessId] as [UA].[AccessId]=(4) AND [SH_Semper].[dbo].[UserAccess].[ProjectMasterId] as [UA].[ProjectMasterId]=CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[UA]" Column="AccessId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(4)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[UA]" Column="ProjectMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(167)" ParameterRuntimeValue="(167)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="10" StatementEstRows="1" StatementId="2" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="IF NOT EXISTS(SELECT * FROM #Document) " StatementType="COND WITH QUERY" QueryHash="0xAF0B76B73C0A6A78" QueryPlanHash="0xBCB0B4CCB60404A4">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="112">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1004" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1004" />
<ScalarOperator ScalarString="CASE WHEN [Expr1005] IS NULL THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1005" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1005" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1005" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="3" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07649BE137]" />
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="11" StatementEstRows="2918.73" StatementId="3" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0914703" StatementText="INSERT #Document (FieldId ,DocumentID) SELECT A.FieldId , B.DocumentMasterId FROM dbo.UserAccess A WITH(NOLOCK) INNER JOIN dbo.DocumentMaster B WITH(NOLOCK) ON A.ProjectMasterId = b.ProjectId WHERE A.[UserMasterId] =@i_UserId AND A.ProjectMasterId=@i_ProjectId AND (B.IsLocked = 0 OR (B.IsLocked = 1 AND B.[STATUS] = @i_UserId) ) " StatementType="INSERT" QueryHash="0x07D8ED14A91048BA" QueryPlanHash="0xB6FB4F6E1BCBB47F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="32" CompileTime="4" CompileCPU="4" CompileMemory="344">
<RelOp AvgRowSize="9" EstimateCPU="0.00291873" EstimateIO="0.0489832" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2918.73" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Clustered Index Insert" EstimatedTotalSubtreeCost="0.0914703">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="true">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC075C18AE3D]" />
<SetPredicate>
<ScalarOperator ScalarString="[#Document].[FieldId] = [Expr1008],[#Document].[DocumentID] = [Expr1009],[#Document].[Id] = [Expr1007],[#Document].[Rejected] = NULL">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#Document]" Column="FieldId" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="DocumentID" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Id" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1007" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Rejected" />
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="19" EstimateCPU="0.000291873" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2918.73" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0395684">
<OutputList>
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[UserAccess].[FieldId] as [A].[FieldId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[DocumentMaster].[DocumentMasterId] as .[DocumentMasterId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="27" EstimateCPU="0.000291873" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2918.73" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0392765">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
<ColumnReference Column="Expr1007" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1007" />
<ScalarOperator ScalarString="getidentity((1513121227),(2),N'#Document')">
<Intrinsic FunctionName="getidentity">
<ScalarOperator>
<Const ConstValue="(1513121227)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(2)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="N'#Document'" />
</ScalarOperator>
</Intrinsic>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="23" EstimateCPU="0.000291873" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2918.73" LogicalOp="Top" NodeId="3" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0389847">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="true" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(0)">
<Const ConstValue="(0)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="23" EstimateCPU="0.0122003" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2918.73" LogicalOp="Inner Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0386928">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<Warnings NoJoinPredicate="true" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<RelOp AvgRowSize="27" EstimateCPU="0.0017135" EstimateIO="0.0120139" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="5.83746" LogicalOp="Clustered Index Scan" NodeId="5" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0137274" TableCardinality="1415">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="5" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[PK_UserAccess]" Alias="[A]" IndexKind="Clustered" />
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[UserAccess].[ProjectMasterId] as [A].[ProjectMasterId]=CONVERT_IMPLICIT(bigint,[@i_ProjectId],0) AND [SH_Semper].[dbo].[UserAccess].[UserMasterId] as [A].[UserMasterId]=[@i_UserId]">
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="ProjectMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
<RelOp AvgRowSize="20" EstimateCPU="0.000707" EstimateIO="0.00365687" EstimateRebinds="0" EstimateRewinds="4.83746" EstimateRows="500" LogicalOp="Index Seek" NodeId="6" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00778395" TableCardinality="9313">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="5" ActualExecutions="5" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[IND000003]" Alias="" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="ProjectId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[IsLocked] as .[IsLocked]=(0) OR [SH_Semper].[dbo].[DocumentMaster].[IsLocked] as .[IsLocked]=(1) AND [SH_Semper].[dbo].[DocumentMaster].[Status] as .[Status]=[@i_UserId]">
<Logical Operation="OR">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(167)" ParameterRuntimeValue="(167)" />
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(12)" ParameterRuntimeValue="(12)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="13" StatementEstRows="1" StatementId="4" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0829822" StatementText="INSERT #temp1 SELECT TOP 1 A.DocumentID FROM #Document A -- LEFT JOIN DataMaster b --ON a.FieldId = b.FieldId -- AND a.DocumentID = b.DocumentId -- WHERE b.DocumentId IS NULL Where A.DocumentID Not IN (Select documentid from DataMaster ) GROUP BY A.DocumentID ORDER BY a.DocumentID " StatementType="INSERT" QueryHash="0x834313FB7482F898" QueryPlanHash="0xFA148C46590C122F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="32" CompileTime="20" CompileCPU="20" CompileMemory="552">
<RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0829822">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
<SetPredicate>
<ScalarOperator ScalarString="[#temp1].[DocID] = #document.[DocumentID] as [A].[DocumentID]">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#temp1]" Column="DocID" />
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="1" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0729812">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="11" EstimateCPU="0.000560996" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="2" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0729811">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues />
<GroupBy>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</GroupBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.86336" LogicalOp="Left Anti Semi Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0729796">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false" WithOrderedPrefetch="true">
<OuterReferences>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1009" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Left Anti Semi Join" NodeId="5" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0687556">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID] IS NULL">
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
<RelOp AvgRowSize="11" EstimateCPU="0.0426352" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Sort" NodeId="6" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0650311">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="false">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0028245" EstimateIO="0.00831019" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2425" LogicalOp="Clustered Index Scan" NodeId="7" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0111347" TableCardinality="2425">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC0779CCD39E]" Alias="[A]" />
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Top" NodeId="8" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00377623">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="2500" ActualExecutions="2500" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.0119035" EstimateIO="0.0802405" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="9" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00377552" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="0" ActualExecutions="2500" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[PK_DataMaster]" IndexKind="Clustered" />
</IndexScan>
</RelOp>
</Top>
</RelOp>
</NestedLoops>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001001" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="5.59009" EstimateRows="1" LogicalOp="Lazy Spool" NodeId="12" Parallel="false" PhysicalOp="Row Count Spool" EstimatedTotalSubtreeCost="0.00426214">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="500" ActualRewinds="2000" ActualRows="2500" ActualEndOfScans="0" ActualExecutions="2500" />
</RunTimeInformation>
<RowCountSpool>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="14" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00347861">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="500" ActualEndOfScans="0" ActualExecutions="500" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.00015993" EstimateIO="0.003125" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="15" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00347838" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="500" ActualEndOfScans="0" ActualExecutions="500" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[IND000001]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Column="DocumentId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID]">
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</Top>
</RelOp>
</RowCountSpool>
</RelOp>
</NestedLoops>
</RelOp>
</StreamAggregate>
</RelOp>
</Top>
</RelOp>
</Update>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="14" StatementEstRows="1" StatementId="5" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="if EXISTS(select * from #temp1) " StatementType="COND WITH QUERY" QueryHash="0x1A42CB848023B8D5" QueryPlanHash="0xD64ABA727B7D8D4F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="104">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1005" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
<ScalarOperator ScalarString="CASE WHEN [Expr1006] THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1006" />
</Identifier>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1006" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1006" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1006" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Table Scan" NodeId="3" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<TableScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
</TableScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="17" StatementEstRows="1" StatementId="6" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0729813" StatementText="SELECT TOP 1 A.DocumentID , 0 AS Rejected FROM #Document A -- LEFT JOIN DataMaster b --ON a.FieldId = b.FieldId -- AND a.DocumentID = b.DocumentId -- WHERE b.DocumentId IS NULL Where A.DocumentID Not IN (Select documentid from DataMaster ) GROUP BY A.DocumentID ORDER BY a.DocumentID " StatementType="SELECT" QueryHash="0x5F38275189DB2B2D" QueryPlanHash="0xA3D478916873EB4D">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="32" CompileTime="17" CompileCPU="17" CompileMemory="528">
<RelOp AvgRowSize="15" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0729813">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1005" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
<ScalarOperator ScalarString="(0)">
<Const ConstValue="(0)" />
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="1" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0729812">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="11" EstimateCPU="0.000560996" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="2" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0729811">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues />
<GroupBy>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</GroupBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.86336" LogicalOp="Left Anti Semi Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0729796">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false" WithOrderedPrefetch="true">
<OuterReferences>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1006" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="0.0101365" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Left Anti Semi Join" NodeId="5" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0687556">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID] IS NULL">
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
<RelOp AvgRowSize="11" EstimateCPU="0.0426352" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="6.18868" LogicalOp="Sort" NodeId="6" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0650311">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="false">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0028245" EstimateIO="0.00831019" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="2425" LogicalOp="Clustered Index Scan" NodeId="7" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0111347" TableCardinality="2425">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC0779CCD39E]" Alias="[A]" />
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Top" NodeId="8" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00377623">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="2500" ActualExecutions="2500" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.0119035" EstimateIO="0.0802405" EstimateRebinds="0" EstimateRewinds="6.18613" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="9" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00377552" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="2500" ActualEndOfScans="0" ActualExecutions="2500" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[PK_DataMaster]" IndexKind="Clustered" />
</IndexScan>
</RelOp>
</Top>
</RelOp>
</NestedLoops>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001001" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="5.59009" EstimateRows="1" LogicalOp="Lazy Spool" NodeId="12" Parallel="false" PhysicalOp="Row Count Spool" EstimatedTotalSubtreeCost="0.00426214">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="500" ActualRewinds="2000" ActualRows="2500" ActualEndOfScans="0" ActualExecutions="2500" />
</RunTimeInformation>
<RowCountSpool>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="14" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00347861">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="500" ActualEndOfScans="0" ActualExecutions="500" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.00015993" EstimateIO="0.003125" EstimateRebinds="1.23518" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="15" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00347838" TableCardinality="10750">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="500" ActualEndOfScans="0" ActualExecutions="500" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[IND000001]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Column="DocumentId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID]">
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</Top>
</RelOp>
</RowCountSpool>
</RelOp>
</NestedLoops>
</RelOp>
</StreamAggregate>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
</BatchSequence>
</ShowPlanXML>
here is 2nd location Execution plan
<?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.1" Build="10.50.6000.34" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
<BatchSequence>
<Batch>
<Statements>
<StmtSimple StatementCompId="7" StatementEstRows="1" StatementId="1" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="IF NOT EXISTS(SELECT UA.AccessId FROM dbo.UserAccess UA WHERE UA.ProjectMasterId = @i_ProjectId AND UA.AccessId = 4 ) " StatementType="COND WITH QUERY" QueryHash="0xA74AB84D9722F10E" QueryPlanHash="0xA7021E71AEE11389">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="344">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1002" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1002" />
<ScalarOperator ScalarString="CASE WHEN [Expr1003] IS NULL THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1003" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1003" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1003" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1003" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="3" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="2466">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[INX00001]" Alias="[UA]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[UA]" Column="ProjectMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[UA]" Column="AccessId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
<ScalarOperator ScalarString="(4)">
<Const ConstValue="(4)" />
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(163)" ParameterRuntimeValue="(163)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="8" StatementEstRows="1" StatementId="2" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0280033" StatementText="INSERT #Document (DocumentID,Rejected ) SELECT TOP 1 [DM].[DocumentId],1 FROM [dbo].[DataMaster] DM WITH(NOLOCK) LEFT JOIN [dbo].[DocumentMaster] DC WITH(NOLOCK) ON [DM].[DocumentId] = [DC].[DocumentMasterId] WHERE [DM].[IsCoded] = 1 AND [DM].[IsRejected]=1 AND [DM].CoderId = @i_UserId AND [DC].[ProjectId] = @i_ProjectId AND (([DC].[IsLocked] = 1 and [DC].[Status] = @i_UserId) OR ([DC].[IsLocked] = 0 AND [DC].[IsChecked] = 1 )) GROUP BY [DM].[DocumentId] ORDER BY [DM].[DocumentId] " StatementType="INSERT" QueryHash="0x66355D87178B8DA3" QueryPlanHash="0xC9BD9E780CA26C7C">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="40" CompileTime="12" CompileCPU="12" CompileMemory="648">
<RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Clustered Index Insert" EstimatedTotalSubtreeCost="0.0280033">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07264DA1B6]" />
<SetPredicate>
<ScalarOperator ScalarString="[#Document].[DocumentID] = [Expr1009],[#Document].[Rejected] = [Expr1007],[#Document].[Id] = [Expr1008],[#Document].[FieldId] = NULL">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#Document]" Column="DocumentID" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Rejected" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1007" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Id" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="FieldId" />
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="19" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0180023">
<OutputList>
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[DataMaster].[DocumentId] as [DM].[DocumentId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="23" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0180022">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="getidentity((610621764),(2),N'#Document')">
<Intrinsic FunctionName="getidentity">
<ScalarOperator>
<Const ConstValue="(610621764)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(2)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="N'#Document'" />
</ScalarOperator>
</Intrinsic>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="19" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="3" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0180021">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
<ColumnReference Column="Expr1007" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1007" />
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="15" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="5" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.018002">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="15" EstimateCPU="5.87508E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Inner Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0180019">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OuterReferences>
<RelOp AvgRowSize="15" EstimateCPU="0.000101092" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.40552" LogicalOp="Distinct Sort" NodeId="7" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0146459">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="true">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="15" EstimateCPU="0.000158546" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.40552" LogicalOp="Index Seek" NodeId="8" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.00328355" TableCardinality="6962">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[INX00002]" Alias="[DM]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="IsCoded" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="IsRejected" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="CoderId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
<ScalarOperator ScalarString="[@i_UserId]">
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="20" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0.40552" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="9" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.00334721" TableCardinality="13266">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="0" ActualExecutions="0" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[PK_DocumentInfo]" Alias="[DC]" IndexKind="Clustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="DocumentMasterId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DataMaster].[DocumentId] as [DM].[DocumentId]">
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Alias="[DM]" Column="DocumentId" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[ProjectId] as [DC].[ProjectId]=CONVERT_IMPLICIT(bigint,[@i_ProjectId],0) AND ([SH_Semper].[dbo].[DocumentMaster].[IsLocked] as [DC].[IsLocked]=(1) AND [SH_Semper].[dbo].[DocumentMaster].[Status] as [DC].[Status]=[@i_UserId] OR [SH_Semper].[dbo].[DocumentMaster].[IsLocked] as [DC].[IsLocked]=(0) AND [SH_Semper].[dbo].[DocumentMaster].[IsChecked] as [DC].[IsChecked]=(1))">
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="ProjectId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="OR">
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="[DC]" Column="IsChecked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(163)" ParameterRuntimeValue="(163)" />
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(236)" ParameterRuntimeValue="(236)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="10" StatementEstRows="1" StatementId="3" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="IF NOT EXISTS(SELECT * FROM #Document) " StatementType="COND WITH QUERY" QueryHash="0xAF0B76B73C0A6A78" QueryPlanHash="0xBCB0B4CCB60404A4">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="112">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1004" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1004" />
<ScalarOperator ScalarString="CASE WHEN [Expr1005] IS NULL THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1005" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1005" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1005" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="3" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07264DA1B6]" />
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="11" StatementEstRows="1" StatementId="4" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0198607" StatementText="INSERT #Document (FieldId ,DocumentID) SELECT A.FieldId , B.DocumentMasterId FROM dbo.UserAccess A WITH(NOLOCK) INNER JOIN dbo.DocumentMaster B WITH(NOLOCK) ON A.ProjectMasterId = b.ProjectId WHERE A.[UserMasterId] =@i_UserId AND A.ProjectMasterId=@i_ProjectId AND (B.IsLocked = 0 OR (B.IsLocked = 1 AND B.[STATUS] = @i_UserId) ) " StatementType="INSERT" QueryHash="0x07D8ED14A91048BA" QueryPlanHash="0x2B595481074A011C">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="40" CompileTime="4" CompileCPU="4" CompileMemory="368">
<RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Clustered Index Insert" EstimatedTotalSubtreeCost="0.0198607">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07264DA1B6]" />
<SetPredicate>
<ScalarOperator ScalarString="[#Document].[FieldId] = [Expr1008],[#Document].[DocumentID] = [Expr1009],[#Document].[Id] = [Expr1007],[#Document].[Rejected] = NULL">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#Document]" Column="FieldId" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="DocumentID" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Id" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1007" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Table="[#Document]" Column="Rejected" />
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="19" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00985972">
<OutputList>
<ColumnReference Column="Expr1007" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[UserAccess].[FieldId] as [A].[FieldId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[SH_Semper].[dbo].[DocumentMaster].[DocumentMasterId] as .[DocumentMasterId],0)">
<Convert DataType="int" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="27" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00985962">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
<ColumnReference Column="Expr1007" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1007" />
<ScalarOperator ScalarString="getidentity((610621764),(2),N'#Document')">
<Intrinsic FunctionName="getidentity">
<ScalarOperator>
<Const ConstValue="(610621764)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(2)" />
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="N'#Document'" />
</ScalarOperator>
</Intrinsic>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="23" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="3" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00985952">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="true" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(0)">
<Const ConstValue="(0)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="23" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Inner Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00985942">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<RelOp AvgRowSize="20" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="5" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="13266">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="938" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="DocumentMasterId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[INX00003]" Alias="" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="ProjectId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[IsLocked] as .[IsLocked]=(0) OR [SH_Semper].[dbo].[DocumentMaster].[IsLocked] as .[IsLocked]=(1) AND [SH_Semper].[dbo].[DocumentMaster].[Status] as .[Status]=[@i_UserId]">
<Logical Operation="OR">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
<ScalarOperator>
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Alias="" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
<RelOp AvgRowSize="19" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Inner Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00657038">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="938" ActualExecutions="938" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserAccessId" />
</OuterReferences>
<RelOp AvgRowSize="15" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Index Seek" NodeId="7" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="2466">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserAccessId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="332052" ActualEndOfScans="938" ActualExecutions="938" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserAccessId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[INX00001]" Alias="[A]" IndexKind="NonClustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="ProjectMasterId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="CONVERT_IMPLICIT(bigint,[@i_ProjectId],0)">
<Identifier>
<ColumnReference Column="ConstExpr1010">
<ScalarOperator>
<Convert DataType="bigint" Style="0" Implicit="true">
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_ProjectId" />
</Identifier>
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
<RelOp AvgRowSize="19" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="9" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="2466">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="330176" ActualExecutions="332052" />
</RunTimeInformation>
<IndexScan Lookup="true" Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="FieldId" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Index="[PK_UserAccess]" Alias="[A]" TableReferenceId="-1" IndexKind="Clustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserAccessId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[UserAccess].[UserAccessId] as [A].[UserAccessId]">
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserAccessId" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
<Predicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[UserAccess].[UserMasterId] as [A].[UserMasterId]=[@i_UserId]">
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[UserAccess]" Alias="[A]" Column="UserMasterId" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</NestedLoops>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_ProjectId" ParameterCompiledValue="(163)" ParameterRuntimeValue="(163)" />
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(236)" ParameterRuntimeValue="(236)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="13" StatementEstRows="1" StatementId="5" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0930089" StatementText="INSERT #temp1 SELECT TOP 1 A.DocumentID FROM #Document A -- LEFT JOIN DataMaster b --ON a.FieldId = b.FieldId -- AND a.DocumentID = b.DocumentId -- WHERE b.DocumentId IS NULL Where A.DocumentID Not IN (Select documentid from DataMaster ) GROUP BY A.DocumentID ORDER BY a.DocumentID " StatementType="INSERT" QueryHash="0x834313FB7482F898" QueryPlanHash="0x7DFCC6DF12CC96E7">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="24" CompileTime="18" CompileCPU="18" CompileMemory="536">
<MissingIndexes>
<MissingIndexGroup Impact="28.05">
<MissingIndex Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]">
<ColumnGroup Usage="EQUALITY">
<Column Name="[DocumentId]" ColumnId="3" />
</ColumnGroup>
</MissingIndex>
</MissingIndexGroup>
</MissingIndexes>
<RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0930089">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
<SetPredicate>
<ScalarOperator ScalarString="[#temp1].[DocID] = #document.[DocumentID] as [A].[DocumentID]">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Table="[#temp1]" Column="DocID" />
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="1" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0830079">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="11" EstimateCPU="0.000553614" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="2" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0830078">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues />
<GroupBy>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</GroupBy>
<RelOp AvgRowSize="11" EstimateCPU="0.00788348" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.54167" LogicalOp="Left Anti Semi Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0830065">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="3" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="0.00788348" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="4.32936" LogicalOp="Left Anti Semi Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0560035">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1703" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID] IS NULL">
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
<RelOp AvgRowSize="11" EstimateCPU="0.032114" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="4.32936" LogicalOp="Sort" NodeId="5" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0524356">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="1703" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="false">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0022316" EstimateIO="0.0068287" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1886" LogicalOp="Clustered Index Scan" NodeId="6" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0090603" TableCardinality="1886">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07264DA1B6]" Alias="[A]" />
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="4.32706" EstimateRows="1" LogicalOp="Top" NodeId="7" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00362807">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1703" ActualEndOfScans="1703" ActualExecutions="1703" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.0077367" EstimateIO="0.061722" EstimateRebinds="0" EstimateRewinds="4.32706" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="8" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00362753" TableCardinality="6962">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1703" ActualEndOfScans="0" ActualExecutions="1703" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[PK_DataMaster]" IndexKind="Clustered" />
</IndexScan>
</RelOp>
</Top>
</RelOp>
</NestedLoops>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001001" EstimateIO="0" EstimateRebinds="3.08334" EstimateRewinds="3.08334" EstimateRows="1" LogicalOp="Lazy Spool" NodeId="11" Parallel="false" PhysicalOp="Row Count Spool" EstimatedTotalSubtreeCost="0.0306729">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="852" ActualRewinds="851" ActualRows="1700" ActualEndOfScans="3" ActualExecutions="1703" />
</RunTimeInformation>
<RowCountSpool>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="3.08334" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="13" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0299551">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="850" ActualEndOfScans="2" ActualExecutions="852" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="15" EstimateCPU="0.0078152" EstimateIO="0.0371991" EstimateRebinds="0" EstimateRewinds="3.08334" EstimateRows="1" LogicalOp="Index Scan" NodeId="14" Parallel="false" PhysicalOp="Index Scan" EstimatedTotalSubtreeCost="0.0254301" TableCardinality="6962">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="850" ActualEndOfScans="2" ActualExecutions="852" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[INX00002]" IndexKind="NonClustered" />
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID]=[SH_Semper].[dbo].[DataMaster].[DocumentId]">
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Column="DocumentId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</Top>
</RelOp>
</RowCountSpool>
</RelOp>
</NestedLoops>
</RelOp>
</StreamAggregate>
</RelOp>
</Top>
</RelOp>
</Update>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="14" StatementEstRows="1" StatementId="6" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.00328854" StatementText="if EXISTS(select * from #temp1) " StatementType="COND WITH QUERY" QueryHash="0x1A42CB848023B8D5" QueryPlanHash="0xD64ABA727B7D8D4F">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="104">
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00328854">
<OutputList>
<ColumnReference Column="Expr1005" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
<ScalarOperator ScalarString="CASE WHEN [Expr1006] THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1006" />
</Identifier>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00328844">
<OutputList>
<ColumnReference Column="Expr1006" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1006" />
</DefinedValue>
</DefinedValues>
<ProbeColumn>
<ColumnReference Column="Expr1006" />
</ProbeColumn>
<RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Constant Scan" NodeId="2" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ConstantScan />
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Table Scan" NodeId="3" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
</TableScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="15" StatementEstRows="1" StatementId="7" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0265743" StatementText="UPDATE [dbo].[DocumentMaster] SET [IsLocked] = 1 ,[LockedTime] = SYSDATETIME() ,[Status] = @i_UserId WHERE [DocumentMasterId] = (select DocID from #temp1) " StatementType="UPDATE" QueryHash="0x2254A6C248573DBF" QueryPlanHash="0x608DE4A7E6988DF7">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" CachedPlanSize="40" CompileTime="4" CompileCPU="4" CompileMemory="416">
<RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0.02" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Update" NodeId="1" Parallel="false" PhysicalOp="Clustered Index Update" EstimatedTotalSubtreeCost="0.0265743">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Update DMLRequestSort="false">
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[PK_DocumentInfo]" IndexKind="Clustered" />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[INX00003]" IndexKind="NonClustered" />
<SetPredicate>
<ScalarOperator ScalarString="[SH_Semper].[dbo].[DocumentMaster].[IsLocked] = [Expr1008],[SH_Semper].[dbo].[DocumentMaster].[LockedTime] = [Expr1009],[SH_Semper].[dbo].[DocumentMaster].[Status] = [@i_UserId]">
<ScalarExpressionList>
<ScalarOperator>
<MultipleAssign>
<Assign>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1008" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="LockedTime" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1009" />
</Identifier>
</ScalarOperator>
</Assign>
<Assign>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Assign>
</MultipleAssign>
</ScalarOperator>
</ScalarExpressionList>
</ScalarOperator>
</SetPredicate>
<RelOp AvgRowSize="28" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657226">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
<ColumnReference Column="Expr1025" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1025" />
<ScalarOperator ScalarString="[Expr1025]">
<Identifier>
<ColumnReference Column="Expr1025" />
</Identifier>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="28" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="3" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657226">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
<ColumnReference Column="Expr1025" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1025" />
<ScalarOperator ScalarString="CASE WHEN [Expr1013] AND [Expr1015] THEN (0) ELSE (1) END">
<IF>
<Condition>
<ScalarOperator>
<Logical Operation="AND">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1013" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1015" />
</Identifier>
</ScalarOperator>
</Logical>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="24" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="4" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657216">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Column="Expr1008" />
<ColumnReference Column="Expr1009" />
<ColumnReference Column="Expr1013" />
<ColumnReference Column="Expr1015" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1008" />
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1009" />
<ScalarOperator ScalarString="CONVERT_IMPLICIT(datetime,sysdatetime(),0)">
<Identifier>
<ColumnReference Column="ConstExpr1016">
<ScalarOperator>
<Convert DataType="datetime" Style="0" Implicit="true">
<ScalarOperator>
<Intrinsic FunctionName="sysdatetime" />
</ScalarOperator>
</Convert>
</ScalarOperator>
</ColumnReference>
</Identifier>
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1015" />
<ScalarOperator ScalarString="CASE WHEN [SH_Semper].[dbo].[DocumentMaster].[Status] = [@i_UserId] THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="BINARY IS">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Column="@i_UserId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="20" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.00657206">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
<ColumnReference Column="Expr1013" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1013" />
<ScalarOperator ScalarString="CASE WHEN [SH_Semper].[dbo].[DocumentMaster].[IsLocked] = (1) THEN (1) ELSE (0) END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="BINARY IS">
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="20" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Inner Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00657196">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Column="Expr1018" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="4.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Assert" NodeId="7" Parallel="false" PhysicalOp="Assert" EstimatedTotalSubtreeCost="0.00328468">
<OutputList>
<ColumnReference Column="Expr1018" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Assert StartupExpression="false">
<RelOp AvgRowSize="19" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="8" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">
<OutputList>
<ColumnReference Column="Expr1017" />
<ColumnReference Column="Expr1018" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1017" />
<ScalarOperator ScalarString="Count(*)">
<Aggregate AggType="countstar" Distinct="false" />
</ScalarOperator>
</DefinedValue>
<DefinedValue>
<ColumnReference Column="Expr1018" />
<ScalarOperator ScalarString="ANY([#temp1].[DocID])">
<Aggregate AggType="ANY" Distinct="false">
<ScalarOperator>
<Identifier>
<ColumnReference Table="[#temp1]" Column="DocID" />
</Identifier>
</ScalarOperator>
</Aggregate>
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="11" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Table Scan" NodeId="9" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1">
<OutputList>
<ColumnReference Table="[#temp1]" Column="DocID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="[#temp1]" Column="DocID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#temp1]" />
</TableScan>
</RelOp>
</StreamAggregate>
</RelOp>
<Predicate>
<ScalarOperator ScalarString="CASE WHEN [Expr1017]>(1) THEN (0) ELSE NULL END">
<IF>
<Condition>
<ScalarOperator>
<Compare CompareOp="GT">
<ScalarOperator>
<Identifier>
<ColumnReference Column="Expr1017" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="(1)" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Condition>
<Then>
<ScalarOperator>
<Const ConstValue="(0)" />
</ScalarOperator>
</Then>
<Else>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Else>
</IF>
</ScalarOperator>
</Predicate>
</Assert>
</RelOp>
<RelOp AvgRowSize="20" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="14" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="13266">
<OutputList>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
</DefinedValue>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="IsLocked" />
</DefinedValue>
<DefinedValue>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="Status" />
</DefinedValue>
</DefinedValues>
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Index="[PK_DocumentInfo]" IndexKind="Clustered" />
<SeekPredicates>
<SeekPredicateNew>
<SeekKeys>
<Prefix ScanType="EQ">
<RangeColumns>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DocumentMaster]" Column="DocumentMasterId" />
</RangeColumns>
<RangeExpressions>
<ScalarOperator ScalarString="[Expr1018]">
<Identifier>
<ColumnReference Column="Expr1018" />
</Identifier>
</ScalarOperator>
</RangeExpressions>
</Prefix>
</SeekKeys>
</SeekPredicateNew>
</SeekPredicates>
</IndexScan>
</RelOp>
</NestedLoops>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</ComputeScalar>
</RelOp>
</Update>
</RelOp>
<ParameterList>
<ColumnReference Column="@i_UserId" ParameterCompiledValue="(236)" ParameterRuntimeValue="(236)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
<Batch>
<Statements>
<StmtSimple StatementCompId="17" StatementEstRows="1" StatementId="8" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.083008" StatementText="SELECT TOP 1 A.DocumentID , 0 AS Rejected FROM #Document A -- LEFT JOIN DataMaster b --ON a.FieldId = b.FieldId -- AND a.DocumentID = b.DocumentId -- WHERE b.DocumentId IS NULL Where A.DocumentID Not IN (Select documentid from DataMaster ) GROUP BY A.DocumentID ORDER BY a.DocumentID " StatementType="SELECT" QueryHash="0x5F38275189DB2B2D" QueryPlanHash="0xF85EB7CD541E338D">
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
<QueryPlan DegreeOfParallelism="1" MemoryGrant="1024" CachedPlanSize="24" CompileTime="14" CompileCPU="14" CompileMemory="520">
<MissingIndexes>
<MissingIndexGroup Impact="31.4295">
<MissingIndex Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]">
<ColumnGroup Usage="EQUALITY">
<Column Name="[DocumentId]" ColumnId="3" />
</ColumnGroup>
</MissingIndex>
</MissingIndexGroup>
</MissingIndexes>
<RelOp AvgRowSize="15" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.083008">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
<ColumnReference Column="Expr1005" />
</OutputList>
<ComputeScalar>
<DefinedValues>
<DefinedValue>
<ColumnReference Column="Expr1005" />
<ScalarOperator ScalarString="(0)">
<Const ConstValue="(0)" />
</ScalarOperator>
</DefinedValue>
</DefinedValues>
<RelOp AvgRowSize="11" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="1" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0830079">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="11" EstimateCPU="0.000553614" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1" LogicalOp="Aggregate" NodeId="2" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0830078">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<StreamAggregate>
<DefinedValues />
<GroupBy>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</GroupBy>
<RelOp AvgRowSize="11" EstimateCPU="0.00788348" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1.54167" LogicalOp="Left Anti Semi Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0830065">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="3" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<OuterReferences>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OuterReferences>
<RelOp AvgRowSize="11" EstimateCPU="0.00788348" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="4.32936" LogicalOp="Left Anti Semi Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0560035">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1703" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<NestedLoops Optimized="false">
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID] IS NULL">
<Compare CompareOp="IS">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Const ConstValue="NULL" />
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
<RelOp AvgRowSize="11" EstimateCPU="0.032114" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="4.32936" LogicalOp="Sort" NodeId="5" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0524356">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<MemoryFractions Input="1" Output="1" />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="1" ActualRewinds="0" ActualRows="1703" ActualEndOfScans="0" ActualExecutions="1" />
</RunTimeInformation>
<Sort Distinct="false">
<OrderBy>
<OrderByColumn Ascending="true">
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OrderByColumn>
</OrderBy>
<RelOp AvgRowSize="11" EstimateCPU="0.0022316" EstimateIO="0.0068287" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="1886" LogicalOp="Clustered Index Scan" NodeId="6" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.0090603" TableCardinality="1886">
<OutputList>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</OutputList>
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1876" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues>
<DefinedValue>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</DefinedValue>
</DefinedValues>
<Object Database="[tempdb]" Schema="[dbo]" Table="[#Document]" Index="[PK__#Documen__3214EC07264DA1B6]" Alias="[A]" />
</IndexScan>
</RelOp>
</Sort>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="4.32706" EstimateRows="1" LogicalOp="Top" NodeId="7" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.00362807">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1703" ActualEndOfScans="1703" ActualExecutions="1703" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="9" EstimateCPU="0.0077367" EstimateIO="0.061722" EstimateRebinds="0" EstimateRewinds="4.32706" EstimateRows="1" LogicalOp="Clustered Index Scan" NodeId="8" Parallel="false" PhysicalOp="Clustered Index Scan" EstimatedTotalSubtreeCost="0.00362753" TableCardinality="6962">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="1703" ActualEndOfScans="0" ActualExecutions="1703" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[PK_DataMaster]" IndexKind="Clustered" />
</IndexScan>
</RelOp>
</Top>
</RelOp>
</NestedLoops>
</RelOp>
<RelOp AvgRowSize="9" EstimateCPU="0.0001001" EstimateIO="0" EstimateRebinds="3.08334" EstimateRewinds="3.08334" EstimateRows="1" LogicalOp="Lazy Spool" NodeId="11" Parallel="false" PhysicalOp="Row Count Spool" EstimatedTotalSubtreeCost="0.0306729">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRebinds="852" ActualRewinds="851" ActualRows="1700" ActualEndOfScans="3" ActualExecutions="1703" />
</RunTimeInformation>
<RowCountSpool>
<RelOp AvgRowSize="9" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="3.08334" EstimateRewinds="0" EstimateRows="1" LogicalOp="Top" NodeId="13" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0299551">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="850" ActualEndOfScans="2" ActualExecutions="852" />
</RunTimeInformation>
<Top RowCount="false" IsPercent="false" WithTies="false">
<TopExpression>
<ScalarOperator ScalarString="(1)">
<Const ConstValue="(1)" />
</ScalarOperator>
</TopExpression>
<RelOp AvgRowSize="15" EstimateCPU="0.0078152" EstimateIO="0.0371991" EstimateRebinds="0" EstimateRewinds="3.08334" EstimateRows="1" LogicalOp="Index Scan" NodeId="14" Parallel="false" PhysicalOp="Index Scan" EstimatedTotalSubtreeCost="0.0254301" TableCardinality="6962">
<OutputList />
<RunTimeInformation>
<RunTimeCountersPerThread Thread="0" ActualRows="850" ActualEndOfScans="2" ActualExecutions="852" />
</RunTimeInformation>
<IndexScan Ordered="false" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false">
<DefinedValues />
<Object Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Index="[INX00002]" IndexKind="NonClustered" />
<Predicate>
<ScalarOperator ScalarString="#document.[DocumentID] as [A].[DocumentID]=[SH_Semper].[dbo].[DataMaster].[DocumentId]">
<Compare CompareOp="EQ">
<ScalarOperator>
<Identifier>
<ColumnReference Table="#Document" Alias="[A]" Column="DocumentID" />
</Identifier>
</ScalarOperator>
<ScalarOperator>
<Identifier>
<ColumnReference Database="[SH_Semper]" Schema="[dbo]" Table="[DataMaster]" Column="DocumentId" />
</Identifier>
</ScalarOperator>
</Compare>
</ScalarOperator>
</Predicate>
</IndexScan>
</RelOp>
</Top>
</RelOp>
</RowCountSpool>
</RelOp>
</NestedLoops>
</RelOp>
</StreamAggregate>
</RelOp>
</Top>
</RelOp>
</ComputeScalar>
</RelOp>
</QueryPlan>
</StmtSimple>
</Statements>
</Batch>
</BatchSequence>
</ShowPlanXML>
Also we observed that if we make datamaster table 0 rows and run application thn taking time less. Can anyone help us to short out slow issue.
Viewing 10 posts - 16 through 24 (of 24 total)
You must be logged in to reply to this topic. Login to reply