Need help with performance...

  • Hi everyone,

    We are currently using SQL Server 2012 Standard (64-bit) on single quad core processor (Intel Xeon E31220) with 12gb ram and Seagate Barracuda ST1000DM003-9YN162 without any raid...

    Total Database size is 480MB and the data table is 40MB and have around 150,000 records. I've already analyzed/applied the query with Database Engine Tuning Advisor but it didn't help at all

    This query from a Stored Procedure is taking 9 seconds to execute which I would like to slow it down below 1 sec...

    Execution Plan download here

    DECLARE

    @cutNVARCHAR(1000) = 'Fair,Good,Very Good,Excellent,Ideal,',

    @ColorNVARCHAR(1000) = 'K,J,I,H,G,F,E,D,',

    @ClarityNVARCHAR(1000) = 'SI2,SI1,VS2,VS1,VVS2,VVS1,IF',

    @CaratMinmoney = 2,

    @CaratMaxmoney = 1800,

    @PriceMinmoney = 0,

    @PriceMaxmoney = 500000,

    @LabIDNVARCHAR(1000) = NULL,

    @PolishNVARCHAR(1000) = 'Good,Very Good,Excellent',

    @SymmetryNVARCHAR(1000) = 'Good,Very Good,Excellent,',

    @DepthMinmoney = 40,

    @DepthMaxmoney = 90,

    @TableMinmoney = 40,

    @TableMaxmoney = 90,

    @FluorescenceNVARCHAR(1000) = 'Very Strong,Strong,Medium,Faint,N/A,',

    @CategoryNVARCHAR(1000) = 'Round',

    @Ordernvarchar(20) = 'asc',

    @OrderBynvarchar(20) = 'Shape',

    @PageNumberint = 1,

    @PageSizeint = 20,

    @MinDaysint = 0,

    @MaxDaysint = 10

    DECLARE @TCutTABLE([Val] [nvarchar](MAX) NULL)

    DECLARE @TColorTABLE([Val] [nvarchar](MAX) NULL)

    DECLARE @TClarityTABLE([Val] [nvarchar](MAX) NULL)

    DECLARE @TLabIDTABLE([Val] INT NULL)

    DECLARE @TPolishTABLE([Val] [nvarchar](MAX) NULL)

    DECLARE @TSymmetryTABLE([Val] [nvarchar](MAX) NULL)

    DECLARE @TFluorescenceTABLE([Val] [nvarchar](MAX) NULL)

    INSERT INTO @TCut SELECT data FROM dbo.Split(@Cut, ',') where data != ''

    INSERT INTO @TColor SELECT data FROM dbo.Split(@Color, ',') where data != ''

    INSERT INTO @TClarity SELECT data FROM dbo.Split(@Clarity, ',') where data != ''

    INSERT INTO @TLabID SELECT data FROM dbo.Split(@LabID, ',') where data != ''

    INSERT INTO @TPolish SELECT data FROM dbo.Split(@Polish, ',') where data != ''

    INSERT INTO @TSymmetry SELECT data FROM dbo.Split(@Symmetry, ',') where data != ''

    INSERT INTO @TFluorescence SELECT data FROM dbo.Split(@Fluorescence, ',') where data != ''

    DECLARE @Cuts INT,

    @Colors INT,

    @Clarities INT,

    @LabIDs INT,

    @Polishes INT,

    @Symmetries INT,

    @Fluorescences INT

    SELECT@Cuts = (SELECT COUNT(*) FROM @TCut),

    @Colors = (SELECT COUNT(*) FROM @TColor),

    @Clarities = (SELECT COUNT(*) FROM @TClarity),

    @LabIDs = (SELECT COUNT(*) FROM @TLabID),

    @Polishes = (SELECT COUNT(*) FROM @TPolish),

    @Symmetries = (SELECT COUNT(*) FROM @TSymmetry),

    @Fluorescences = (SELECT COUNT(*) FROM @TFluorescence)

    IF @CaratMin < 1 OR @CaratMin IS NULL

    SELECT @CaratMin = 2

    IF @CaratMax < 1 OR @CaratMax IS NULL

    SELECT @CaratMax = 1800

    SELECT @CaratMin = @CaratMin / 100, @CaratMax = @CaratMax / 100

    IF @PriceMin < 1 OR @PriceMin IS NULL

    SELECT @PriceMin = 0

    IF @PriceMax < 1 OR @PriceMax IS NULL

    SELECT @PriceMax = 500000

    IF @DepthMin < 40 OR @DepthMin IS NULL

    SELECT @DepthMin = 40

    IF @DepthMax < 40 OR @DepthMax IS NULL

    SELECT @DepthMax = 90

    IF @TableMin < 40 OR @TableMin IS NULL

    SELECT @TableMin = 40

    IF @TableMax < 40 OR @TableMax IS NULL

    SELECT @TableMax = 90

    SET STATISTICS TIME ON

    ;WITH CTE AS

    (

    SELECT

    Row_Number() OVER(ORDER BY LabID, FinalPrice, [Weight]) RowID,

    D.*

    FROM Dia D

    INNER JOIN DiaVendor DV

    ON D.DiaVendorID = DV.ID

    WHERE SoldOut = 0

    AND DiaVendorID IS NOT NULL

    AND ISNULL(MinDeliveryDays, 5) >= @MinDays AND ISNULL(MinDeliveryDays, 1) <= @MaxDays

    AND FinalPrice >= @PriceMin

    AND FinalPrice <= @PriceMax

    AND [Weight] >= @CaratMin

    AND [Weight] <= @CaratMax

    AND Depth >= @DepthMin

    AND Depth <= @DepthMax

    AND [Table] >= @TableMin

    AND [Table] <= @TableMax

    AND SHAPE = @Category

    AND (@LabIDs = 0 OR EXISTS(SELECT Val FROM @TLabID WHERE Val = LabID))

    AND (@Cuts = 0 OR Shape != 'Round' OR EXISTS(SELECT Val FROM @TCut WHERE Val = Cut))

    AND (@Polishes = 0 OR EXISTS(SELECT Val FROM @TPolish WHERE Val = Polish))

    AND (@Symmetries = 0 OR EXISTS(SELECT Val FROM @TSymmetry WHERE Val = Symmetry))

    AND (@Colors = 0 OR EXISTS(SELECT Val FROM @TColor WHERE Val = Color))

    AND (@Clarities = 0 OR EXISTS(SELECT Val FROM @TClarity WHERE Val = Clarity))

    AND (@Fluorescences = 0 OR EXISTS(SELECT Val FROM @TFluorescence WHERE Val = FluorescenceIntensity))

    --AND (@LabIDs = 0 OR LabID IN (SELECT Val FROM @TLabID))

    --AND (@Cuts = 0 OR Shape != 'Round' OR Cut IN (SELECT Val FROM @TCut))

    --AND (@Polishes = 0 OR Polish IN (SELECT Val FROM @TPolish))

    --AND (@Symmetries = 0 OR Symmetry IN (SELECT Val FROM @TSymmetry))

    --AND (@Colors = 0 OR Color IN (SELECT Val FROM @TColor))

    --AND (@Clarities = 0 OR Clarity IN (SELECT Val FROM @TClarity))

    --AND (@Fluorescences = 0 OR FluorescenceIntensity IN (SELECT Val FROM @TFluorescence))

    )

    SELECT

    [DiamondID]

    ,[Shape]

    ,[Weight]

    ,[Color]

    ,[Clarity]

    ,[Cut]

    ,[LabID]

    ,[Lab]

    ,CAST((SELECT COUNT(*) FROM CTE) AS money) [RapNetPrice]

    ,[FinalPrice]

    ,[CertificateNumber]

    ,[VendorStockNumber]

    ,[Symmetry]

    ,[Polish]

    ,[Depth]

    ,[Table]

    ,[MeasLength]

    ,[MeasWidth]

    ,[MeasDepth]

    ,[GirdleMin]

    ,[GirdleMax]

    ,[GirdleCondition]

    ,[CuletSize]

    ,[CuletCondition]

    ,[FluorescenceColor]

    ,[FluorescenceIntensity]

    ,[HasCertFile]

    ,[DiaVendorID]

    ,[SoldOut]

    FROM CTE

    WHERE RowID BETWEEN @PageNumber * @PageSize - @PageSize + 1 AND @PageNumber * @PageSize

    SET STATISTICS TIME OFF

    Statistics

    Table 'DiaVendor'. Scan count 248284, logical reads 496568, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#BB3E5626'. Scan count 2, logical reads 251030, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B76DC542'. Scan count 2, logical reads 251030, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B679A109'. Scan count 2, logical reads 251030, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#BA4A31ED'. Scan count 2, logical reads 252428, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B9560DB4'. Scan count 2, logical reads 252670, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B5857CD0'. Scan count 2, logical reads 252670, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'Dia'. Scan count 2, logical reads 384033, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

  • Hi,

    Can you please post the actual execution plan and statistics ?

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Please download it form here

    Table 'DiaVendor'. Scan count 248284, logical reads 496568, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#BB3E5626'. Scan count 2, logical reads 251030, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B76DC542'. Scan count 2, logical reads 251030, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B679A109'. Scan count 2, logical reads 251030, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#BA4A31ED'. Scan count 2, logical reads 252428, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B9560DB4'. Scan count 2, logical reads 252670, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table '#B5857CD0'. Scan count 2, logical reads 252670, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'Dia'. Scan count 2, logical reads 384033, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

  • Quick questions, what is the tempdb configuration and can you post the code for the dbo.Split function?

    😎

    BTW: Consider posting the full execution plan in XML format, the information you posted aren't helpful at all.

  • Actual execution plan please?

    In the mean time, first thing to try is to replace all those table variables with temp tables. So:

    CREATE TABLE #TCut([Val] [nvarchar](MAX) NULL)

    CREATE TABLE #TColor([Val] [nvarchar](MAX) NULL)

    CREATE TABLE #TClarity([Val] [nvarchar](MAX) NULL)

    CREATE TABLE #TLabID([Val] INT NULL)

    CREATE TABLE #TPolish([Val] [nvarchar](MAX) NULL)

    CREATE TABLE #TSymmetry([Val] [nvarchar](MAX) NULL)

    CREATE TABLE #TFluorescence([Val] [nvarchar](MAX) NULL)

    And then change the names within the rest of the code (and while you're at it, replace the nvarchar(max) with a more appropriate data type. Varchar(N) or NVarchar(N) as applicable. I doubt a gemstome's cut is over 8000 characters long. Based on your example data, varchar(100) would be more than adequate.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • TempDB Details,

    Size : 573mb

    Space Available : 505mb

    num_of_writes 1560971

    avg_write_stall_ms11.49514693098078055944612

    num_of_reads 944612

    avg_read_stall_ms 4.46061239958840243

    Split Function

    ALTER FUNCTION [dbo].[Split]

    (

    @string VARCHAR(MAX),

    @delimiter CHAR(1)

    )

    RETURNS @output TABLE(

    data NVARCHAR(256)

    )

    BEGIN

    DECLARE @start INT, @end INT

    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)

    WHILE @start < LEN(@string) + 1 BEGIN

    IF @end = 0

    SET @end = LEN(@string) + 1

    INSERT INTO @output (data)

    VALUES(SUBSTRING(@string, @start, @end - @start))

    SET @start = @end + 1

    SET @end = CHARINDEX(@delimiter, @string, @start)

    END

    RETURN

    END

    Changed the code to #tables

    DECLARE

    @cutNVARCHAR(250) = 'Fair,Good,Very Good,Excellent,Ideal,',

    @ColorNVARCHAR(250) = 'K,J,I,H,G,F,E,D,',

    @ClarityNVARCHAR(250) = 'SI2,SI1,VS2,VS1,VVS2,VVS1,IF',

    @CaratMinmoney = 2,

    @CaratMaxmoney = 1800,

    @PriceMinmoney = 0,

    @PriceMaxmoney = 500000,

    @LabIDNVARCHAR(250) = NULL,

    @PolishNVARCHAR(250) = 'Good,Very Good,Excellent',

    @SymmetryNVARCHAR(250) = 'Good,Very Good,Excellent,',

    @DepthMinmoney = 40,

    @DepthMaxmoney = 90,

    @TableMinmoney = 40,

    @TableMaxmoney = 90,

    @FluorescenceNVARCHAR(250) = 'Very Strong,Strong,Medium,Faint,N/A,',

    @CategoryNVARCHAR(250) = 'Round',

    @Ordernvarchar(20) = 'asc',

    @OrderBynvarchar(20) = 'Shape',

    @PageNumberint = 1,

    @PageSizeint = 20,

    @MinDaysint = 0,

    @MaxDaysint = 10

    CREATE TABLE #TCut([Val] [nvarchar](250) NULL)

    CREATE TABLE #TColor([Val] [nvarchar](250) NULL)

    CREATE TABLE #TClarity([Val] [nvarchar](250) NULL)

    CREATE TABLE #TLabID([Val] INT NULL)

    CREATE TABLE #TPolish([Val] [nvarchar](250) NULL)

    CREATE TABLE #TSymmetry([Val] [nvarchar](250) NULL)

    CREATE TABLE #TFluorescence([Val] [nvarchar](250) NULL)

    INSERT INTO #TCut SELECT data FROM dbo.Split(@Cut, ',') where data != ''

    INSERT INTO #TColor SELECT data FROM dbo.Split(@Color, ',') where data != ''

    INSERT INTO #TClarity SELECT data FROM dbo.Split(@Clarity, ',') where data != ''

    INSERT INTO #TLabID SELECT data FROM dbo.Split(@LabID, ',') where data != ''

    INSERT INTO #TPolish SELECT data FROM dbo.Split(@Polish, ',') where data != ''

    INSERT INTO #TSymmetry SELECT data FROM dbo.Split(@Symmetry, ',') where data != ''

    INSERT INTO #TFluorescence SELECT data FROM dbo.Split(@Fluorescence, ',') where data != ''

    DECLARE @Cuts INT,

    @Colors INT,

    @Clarities INT,

    @LabIDs INT,

    @Polishes INT,

    @Symmetries INT,

    @Fluorescences INT

    SELECT@Cuts = (SELECT COUNT(*) FROM #TCut),

    @Colors = (SELECT COUNT(*) FROM #TColor),

    @Clarities = (SELECT COUNT(*) FROM #TClarity),

    @LabIDs = (SELECT COUNT(*) FROM #TLabID),

    @Polishes = (SELECT COUNT(*) FROM #TPolish),

    @Symmetries = (SELECT COUNT(*) FROM #TSymmetry),

    @Fluorescences = (SELECT COUNT(*) FROM #TFluorescence)

    IF @CaratMin < 1 OR @CaratMin IS NULL

    SELECT @CaratMin = 2

    IF @CaratMax < 1 OR @CaratMax IS NULL

    SELECT @CaratMax = 1800

    SELECT @CaratMin = @CaratMin / 100, @CaratMax = @CaratMax / 100

    IF @PriceMin < 1 OR @PriceMin IS NULL

    SELECT @PriceMin = 0

    IF @PriceMax < 1 OR @PriceMax IS NULL

    SELECT @PriceMax = 500000

    IF @DepthMin < 40 OR @DepthMin IS NULL

    SELECT @DepthMin = 40

    IF @DepthMax < 40 OR @DepthMax IS NULL

    SELECT @DepthMax = 90

    IF @TableMin < 40 OR @TableMin IS NULL

    SELECT @TableMin = 40

    IF @TableMax < 40 OR @TableMax IS NULL

    SELECT @TableMax = 90

    SET STATISTICS TIME ON

    ;WITH CTE AS

    (

    SELECT

    Row_Number() OVER(ORDER BY LabID, FinalPrice, [Weight]) RowID,

    D.*

    FROM Dia D

    INNER JOIN DiaVendor DV

    ON D.DiaVendorID = DV.ID

    WHERE SoldOut = 0

    AND DiaVendorID IS NOT NULL

    AND ISNULL(MinDeliveryDays, 5) >= @MinDays AND ISNULL(MinDeliveryDays, 1) <= @MaxDays

    AND FinalPrice >= @PriceMin

    AND FinalPrice <= @PriceMax

    AND [Weight] >= @CaratMin

    AND [Weight] <= @CaratMax

    AND Depth >= @DepthMin

    AND Depth <= @DepthMax

    AND [Table] >= @TableMin

    AND [Table] <= @TableMax

    AND SHAPE = @Category

    AND (@LabIDs = 0 OR EXISTS(SELECT Val FROM #TLabID WHERE Val = LabID))

    AND (@Cuts = 0 OR Shape != 'Round' OR EXISTS(SELECT Val FROM #TCut WHERE Val = Cut))

    AND (@Polishes = 0 OR EXISTS(SELECT Val FROM #TPolish WHERE Val = Polish))

    AND (@Symmetries = 0 OR EXISTS(SELECT Val FROM #TSymmetry WHERE Val = Symmetry))

    AND (@Colors = 0 OR EXISTS(SELECT Val FROM #TColor WHERE Val = Color))

    AND (@Clarities = 0 OR EXISTS(SELECT Val FROM #TClarity WHERE Val = Clarity))

    AND (@Fluorescences = 0 OR EXISTS(SELECT Val FROM #TFluorescence WHERE Val = FluorescenceIntensity))

    --AND (@LabIDs = 0 OR LabID IN (SELECT Val FROM #TLabID))

    --AND (@Cuts = 0 OR Shape != 'Round' OR Cut IN (SELECT Val FROM #TCut))

    --AND (@Polishes = 0 OR Polish IN (SELECT Val FROM #TPolish))

    --AND (@Symmetries = 0 OR Symmetry IN (SELECT Val FROM #TSymmetry))

    --AND (@Colors = 0 OR Color IN (SELECT Val FROM #TColor))

    --AND (@Clarities = 0 OR Clarity IN (SELECT Val FROM #TClarity))

    --AND (@Fluorescences = 0 OR FluorescenceIntensity IN (SELECT Val FROM #TFluorescence))

    )

    SELECT

    [DiamondID]

    ,[Shape]

    ,[Weight]

    ,[Color]

    ,[Clarity]

    ,[Cut]

    ,[LabID]

    ,[Lab]

    ,CAST((SELECT COUNT(*) FROM CTE) AS money) [RapNetPrice]

    ,[FinalPrice]

    ,[CertificateNumber]

    ,[VendorStockNumber]

    ,[Symmetry]

    ,[Polish]

    ,[Depth]

    ,[Table]

    ,[MeasLength]

    ,[MeasWidth]

    ,[MeasDepth]

    ,[GirdleMin]

    ,[GirdleMax]

    ,[GirdleCondition]

    ,[CuletSize]

    ,[CuletCondition]

    ,[FluorescenceColor]

    ,[FluorescenceIntensity]

    ,[HasCertFile]

    ,[DiaVendorID]

    ,[SoldOut]

    FROM CTE

    WHERE RowID BETWEEN @PageNumber * @PageSize - @PageSize + 1 AND @PageNumber * @PageSize

    SET STATISTICS TIME OFF

    DROP TABLE #TCut

    DROP TABLE #TColor

    DROP TABLE #TClarity

    DROP TABLE #TLabID

    DROP TABLE #TPolish

    DROP TABLE #TSymmetry

    DROP TABLE #TFluorescence

    <?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.2" Build="11.0.2100.60" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">

    <BatchSequence>

    <Batch>

    <Statements>

    <StmtUseDb StatementCompId="1" StatementId="1" StatementText="USE TJDB " StatementType="USE DATABASE" RetrievedFromCache="false" Database="[TJDB]" />

    </Statements>

    </Batch>

    <Batch>

    <Statements>

    <StmtSimple StatementCompId="1" StatementId="1" StatementText=" DECLARE @cutNVARCHAR(250) = 'Fair,Good,Very Good,Excellent,Ideal,', @ColorNVARCHAR(250) = 'K,J,I,H,G,F,E,D,', @ClarityNVARCHAR(250) = 'SI2,SI1,VS2,VS1,VVS2,VVS1,IF', @CaratMinmoney = 2, @CaratMaxmoney = 1800, @PriceMinmoney = 0, @PriceMaxmoney = 500000, @LabIDNVARCHAR(250) = NULL, @PolishNVARCHAR(250) = 'Good,Very Good,Excellent', @SymmetryNVARCHAR(250) = 'Good,Very Good,Excellent,', @DepthMinmoney = 40, @DepthMaxmoney = 90, @TableMinmoney = 40, @TableMaxmoney = 90, @FluorescenceNVARCHAR(250) = 'Very Strong,Strong,Medium,Faint,N/A,', @CategoryNVARCHAR(250) = 'Round', @Ordernvarchar(20) = 'asc', @OrderBynvarchar(20) = 'Shape', @PageNumberint = 1, @PageSizeint = 20, @MinDaysint = 0, @MaxDaysint = 10 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="2" StatementId="2" StatementText=" CREATE TABLE #TCut([Val] [nvarchar](250) NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="3" StatementId="3" StatementText=" CREATE TABLE #TColor([Val] [nvarchar](250) NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="4" StatementId="4" StatementText=" CREATE TABLE #TClarity([Val] [nvarchar](250) NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="5" StatementId="5" StatementText=" CREATE TABLE #TLabID([Val] INT NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="6" StatementId="6" StatementText=" CREATE TABLE #TPolish([Val] [nvarchar](250) NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="7" StatementId="7" StatementText=" CREATE TABLE #TSymmetry([Val] [nvarchar](250) NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="8" StatementId="8" StatementText=" CREATE TABLE #TFluorescence([Val] [nvarchar](250) NULL) " StatementType="CREATE TABLE" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="9" StatementEstRows="1" StatementId="9" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TCut SELECT data FROM dbo.Split(@Cut, ',') where data != '' " StatementType="INSERT" QueryHash="0x8B3C9547A74EDF15" QueryPlanHash="0x9C58CAC97B3A5087" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@Cut],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Cut" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TCut].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="519" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(250),[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="nvarchar" Length="500" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="10" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="11" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="12" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="13" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="14" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="15" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="16" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="17" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="10" StatementEstRows="1" StatementId="18" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TColor SELECT data FROM dbo.Split(@Color, ',') where data != '' " StatementType="INSERT" QueryHash="0x27DB819D79612986" QueryPlanHash="0x94370332EB286249" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@Color],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Color" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TColor].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="519" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(250),[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="nvarchar" Length="500" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="19" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="20" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="21" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="22" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="23" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="24" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="25" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="26" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="11" StatementEstRows="1" StatementId="27" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TClarity SELECT data FROM dbo.Split(@Clarity, ',') where data != '' " StatementType="INSERT" QueryHash="0x86366AD823B74AB" QueryPlanHash="0x47B288C2D928A486" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@Clarity],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Clarity" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TClarity].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="519" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(250),[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="nvarchar" Length="500" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="28" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="29" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="30" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="31" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="32" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="33" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="34" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="35" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="12" StatementEstRows="1" StatementId="36" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TLabID SELECT data FROM dbo.Split(@LabID, ',') where data != '' " StatementType="INSERT" QueryHash="0x56658F4B73CEEAD6" QueryPlanHash="0x223E162063EB8389" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@LabID],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@LabID" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TLabID].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="271" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="37" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="38" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="39" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="40" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="41" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="42" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="43" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="44" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="13" StatementEstRows="1" StatementId="45" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TPolish SELECT data FROM dbo.Split(@Polish, ',') where data != '' " StatementType="INSERT" QueryHash="0x3090698A2BFB1620" QueryPlanHash="0xC61A2D939E89E2B7" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@Polish],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Polish" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TPolish].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="519" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(250),[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="nvarchar" Length="500" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="46" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="47" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="48" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="49" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="50" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="51" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="52" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="53" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="14" StatementEstRows="1" StatementId="54" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TSymmetry SELECT data FROM dbo.Split(@Symmetry, ',') where data != '' " StatementType="INSERT" QueryHash="0xD8F1808E6F105CAC" QueryPlanHash="0x96C053F0F5320D95" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@Symmetry],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Symmetry" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TSymmetry].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="519" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(250),[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="nvarchar" Length="500" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="55" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="56" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="57" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="58" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="59" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="60" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="61" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="62" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="15" StatementEstRows="1" StatementId="63" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0132878" StatementText=" INSERT INTO #TFluorescence SELECT data FROM dbo.Split(@Fluorescence, ',') where data != '' " StatementType="INSERT" QueryHash="0x6A1DD3B40B065B7F" QueryPlanHash="0x72F81F9A683194F5" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="16" CompileTime="1" CompileCPU="1" CompileMemory="176">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="2E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sequence" NodeId="0" Parallel="false" PhysicalOp="Sequence" EstimatedTotalSubtreeCost="0.0132878">

    <OutputList />

    <Sequence>

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table-valued function" NodeId="1" Parallel="false" PhysicalOp="Table-valued function" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <TableValuedFunction>

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <ParameterList>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(varchar(max),[@Fluorescence],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1008">

    <ScalarOperator>

    <Convert DataType="varchar(max)" Length="2147483647" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Fluorescence" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="','">

    <Const ConstValue="','" />

    </ScalarOperator>

    </ParameterList>

    </TableValuedFunction>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="4" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0132847">

    <OutputList />

    <Update DMLRequestSort="false">

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" IndexKind="Heap" />

    <SetPredicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TFluorescence].[Val] = [Expr1006]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" Column="Val" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1006" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    <RelOp AvgRowSize="519" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="5" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032832">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(250),[TJDB].[dbo].[Split].[data],0)">

    <Convert DataType="nvarchar" Length="500" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="267" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="6" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </OutputList>

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Split]" />

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Split].[data]<>N''">

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Split]" Column="data" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N''" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Update>

    </RelOp>

    </Sequence>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple>

    <UDF ProcName="[TJDB].[dbo].[Split]">

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="64" StatementText=" CREATE FUNCTION [dbo].[Split] ( @string VARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(256) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtCond StatementCompId="50" StatementId="65" StatementText=" WHILE @start < LEN(@string) + 1" StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtCond StatementCompId="51" StatementId="66" StatementText=" BEGIN IF @end = 0 " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="52" StatementId="67" StatementText=" SET @end = LEN(@string) + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="54" StatementEstRows="1" StatementId="68" StatementOptmLevel="TRIVIAL" StatementSubTreeCost="0.0100022" StatementText=" INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) " StatementType="INSERT" QueryHash="0xF32DE0D5BCCE7C47" QueryPlanHash="0x91E83678F554D831" RetrievedFromCache="true">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="16" CompileTime="0" CompileCPU="0" CompileMemory="136">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="9" EstimateCPU="1E-06" EstimateIO="0.01" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Insert" NodeId="0" Parallel="false" PhysicalOp="Table Insert" EstimatedTotalSubtreeCost="0.0100022">

    <OutputList />

    <ScalarInsert DMLRequestSort="false">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(256),substring([@string],CONVERT_IMPLICIT(bigint,[@start],0),CONVERT_IMPLICIT(bigint,[@end]-[@start],0)),0)">

    <Convert DataType="nvarchar" Length="512" Style="0" Implicit="true">

    <ScalarOperator>

    <Intrinsic FunctionName="substring">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@string" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@end" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@start" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <Object Table="[@output]" />

    <SetPredicate>

    <ScalarOperator ScalarString="[data] = [Expr1004]">

    <ScalarExpressionList>

    <ScalarOperator>

    <MultipleAssign>

    <Assign>

    <ColumnReference Column="data" />

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </Assign>

    </MultipleAssign>

    </ScalarOperator>

    </ScalarExpressionList>

    </ScalarOperator>

    </SetPredicate>

    </ScalarInsert>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@string" ParameterCompiledValue="NULL" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    <StmtSimple StatementCompId="55" StatementId="69" StatementText=" SET @start = @end + 1 " StatementType="ASSIGN" RetrievedFromCache="true" />

    <StmtSimple StatementCompId="56" StatementId="70" StatementText=" SET @end = CHARINDEX(@delimiter, @string, @start) " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    <StmtSimple StatementCompId="59" StatementId="71" StatementText=" END RETURN " StatementType="RETURN NONE" RetrievedFromCache="true" />

    </Statements>

    </UDF>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="16" StatementEstRows="1" StatementId="72" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.0230146" StatementText=" DECLARE @Cuts INT, @Colors INT, @Clarities INT, @LabIDs INT, @Polishes INT, @Symmetries INT, @Fluorescences INT SELECT@Cuts = (SELECT COUNT(*) FROM #TCut), @Colors = (SELECT COUNT(*) FROM #TColor), @Clarities = (SELECT COUNT(*) FROM #TClarity), @LabIDs = (SELECT COUNT(*) FROM #TLabID), @Polishes = (SELECT COUNT(*) FROM #TPolish), @Symmetries = (SELECT COUNT(*) FROM #TSymmetry), @Fluorescences = (SELECT COUNT(*) FROM #TFluorescence) " StatementType="SELECT" QueryHash="0x78D515E859EF2811" QueryPlanHash="0x10FD081D35541A74" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="48" CompileTime="9" CompileCPU="9" CompileMemory="800">

    <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="35" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0230146">

    <OutputList>

    <ColumnReference Column="Expr1006" />

    <ColumnReference Column="Expr1013" />

    <ColumnReference Column="Expr1020" />

    <ColumnReference Column="Expr1027" />

    <ColumnReference Column="Expr1034" />

    <ColumnReference Column="Expr1041" />

    <ColumnReference Column="Expr1048" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1006" />

    <ScalarOperator ScalarString="[Expr1004]">

    <Identifier>

    <ColumnReference Column="Expr1004" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1013" />

    <ScalarOperator ScalarString="[Expr1011]">

    <Identifier>

    <ColumnReference Column="Expr1011" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1020" />

    <ScalarOperator ScalarString="[Expr1018]">

    <Identifier>

    <ColumnReference Column="Expr1018" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1027" />

    <ScalarOperator ScalarString="[Expr1025]">

    <Identifier>

    <ColumnReference Column="Expr1025" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1034" />

    <ScalarOperator ScalarString="[Expr1032]">

    <Identifier>

    <ColumnReference Column="Expr1032" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1041" />

    <ScalarOperator ScalarString="[Expr1039]">

    <Identifier>

    <ColumnReference Column="Expr1039" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1048" />

    <ScalarOperator ScalarString="[Expr1046]">

    <Identifier>

    <ColumnReference Column="Expr1046" />

    </Identifier>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="35" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0230145">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    <ColumnReference Column="Expr1011" />

    <ColumnReference Column="Expr1018" />

    <ColumnReference Column="Expr1025" />

    <ColumnReference Column="Expr1032" />

    <ColumnReference Column="Expr1039" />

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="31" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="2" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0197261">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    <ColumnReference Column="Expr1018" />

    <ColumnReference Column="Expr1025" />

    <ColumnReference Column="Expr1032" />

    <ColumnReference Column="Expr1039" />

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="27" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="3" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0164377">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    <ColumnReference Column="Expr1025" />

    <ColumnReference Column="Expr1032" />

    <ColumnReference Column="Expr1039" />

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="23" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0131493">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    <ColumnReference Column="Expr1032" />

    <ColumnReference Column="Expr1039" />

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="19" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="5" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00986096">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    <ColumnReference Column="Expr1039" />

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="15" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.00657258">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="7" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1004" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1004" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1063],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1063" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="8" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1063" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1063" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="9" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="14" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1046" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1046" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1064],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1064" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="15" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1064" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1064" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="16" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="21" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1039" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1039" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1065],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1065" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="22" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1065" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1065" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="23" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="28" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1032" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1032" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1066],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1066" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="29" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1066" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1066" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="30" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="35" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1025" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1025" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1067],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1067" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="36" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1067" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1067" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="37" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="42" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1018" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1018" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1068],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1068" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="43" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1068" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1068" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="44" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="49" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1011" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1011" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1069],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1069" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="50" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0032842">

    <OutputList>

    <ColumnReference Column="Expr1069" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1069" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="51" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" IndexKind="Heap" />

    </TableScan>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="17" StatementId="73" StatementText=" IF @CaratMin < 1 OR @CaratMin IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="18" StatementId="74" StatementText="SELECT @CaratMin = 2 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="20" StatementId="75" StatementText=" IF @CaratMax < 1 OR @CaratMax IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="21" StatementId="76" StatementText="SELECT @CaratMax = 1800 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="23" StatementId="77" StatementText=" SELECT @CaratMin = @CaratMin / 100, @CaratMax = @CaratMax / 100 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtCond StatementCompId="24" StatementId="78" StatementText=" IF @PriceMin < 1 OR @PriceMin IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="25" StatementId="79" StatementText="SELECT @PriceMin = 0 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="27" StatementId="80" StatementText=" IF @PriceMax < 1 OR @PriceMax IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="28" StatementId="81" StatementText="SELECT @PriceMax = 500000 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="30" StatementId="82" StatementText=" IF @DepthMin < 40 OR @DepthMin IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="31" StatementId="83" StatementText="SELECT @DepthMin = 40 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="33" StatementId="84" StatementText=" IF @DepthMax < 40 OR @DepthMax IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="34" StatementId="85" StatementText="SELECT @DepthMax = 90 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="36" StatementId="86" StatementText=" IF @TableMin < 40 OR @TableMin IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="37" StatementId="87" StatementText="SELECT @TableMin = 40 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtCond StatementCompId="39" StatementId="88" StatementText=" IF @TableMax < 40 OR @TableMax IS NULL " StatementType="COND" RetrievedFromCache="true">

    <Condition />

    <Then>

    <Statements>

    <StmtSimple StatementCompId="40" StatementId="89" StatementText="SELECT @TableMax = 90 " StatementType="ASSIGN" RetrievedFromCache="true" />

    </Statements>

    </Then>

    </StmtCond>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="42" StatementId="90" StatementText=" SET STATISTICS TIME ON " StatementType="SET STATS" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="43" StatementEstRows="1" StatementId="91" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" StatementSubTreeCost="0.137992" StatementText=";WITH CTE AS ( SELECT Row_Number() OVER(ORDER BY LabID, FinalPrice, [Weight]) RowID, D.* FROM Dia D INNER JOIN DiaVendor DV ON D.DiaVendorID = DV.ID WHERE SoldOut = 0 AND DiaVendorID IS NOT NULL AND ISNULL(MinDeliveryDays, 5) >= @MinDays AND ISNULL(MinDeliveryDays, 1) <= @MaxDays AND FinalPrice >= @PriceMin AND FinalPrice <= @PriceMax AND [Weight] >= @CaratMin AND [Weight] <= @CaratMax AND Depth >= @DepthMin AND Depth <= @DepthMax AND [Table] >= @TableMin AND [Table] <= @TableMax AND SHAPE = @Category AND (@LabIDs = 0 OR EXISTS(SELECT Val FROM #TLabID WHERE Val = LabID)) AND (@Cuts = 0 OR Shape != 'Round' OR EXISTS(SELECT Val FROM #TCut WHERE Val = Cut)) AND (@Polishes = 0 OR EXISTS(SELECT Val FROM #TPolish WHERE Val = Polish)) AND (@Symmetries = 0 OR EXISTS(SELECT Val FROM #TSymmetry WHERE Val = Symmetry)) AND (@Colors = 0 OR EXISTS(SELECT Val FROM #TColor WHERE Val = Color)) AND (@Clarities = 0 OR EXISTS(SELECT Val FROM #TClarity WHERE Val = Clarity)) AND (@Fluorescences = 0 OR EXISTS(SELECT Val FROM #TFluorescence WHERE Val = FluorescenceIntensity)) --AND (@LabIDs = 0 OR LabID IN (SELECT Val FROM #TLabID)) --AND (@Cuts = 0 OR Shape != 'Round' OR Cut IN (SELECT Val FROM #TCut)) --AND (@Polishes = 0 OR Polish IN (SELECT Val FROM #TPolish)) --AND (@Symmetries = 0 OR Symmetry IN (SELECT Val FROM #TSymmetry)) --AND (@Colors = 0 OR Color IN (SELECT Val FROM #TColor)) --AND (@Clarities = 0 OR Clarity IN (SELECT Val FROM #TClarity)) --AND (@Fluorescences = 0 OR FluorescenceIntensity IN (SELECT Val FROM #TFluorescence)) ) SELECT [DiamondID] ,[Shape] ,[Weight] ,[Color] ,[Clarity] ,[Cut] ,[LabID] ,[Lab] ,CAST((SELECT COUNT(*) FROM CTE) AS money) [RapNetPrice] ,[FinalPrice] ,[CertificateNumber] ,[VendorStockNumber] ,[Symmetry] ,[Polish] ,[Depth] ,[Table] ,[MeasLength] ,[MeasWidth] ,[MeasDepth] ,[GirdleMin] ,[GirdleMax] ,[GirdleCondition] ,[CuletSize] ,[CuletCondition] ,[FluorescenceColor] ,[FluorescenceIntensity] ,[HasCertFile] ,[DiaVendorID] ,[SoldOut] FROM CTE WHERE RowID BETWEEN @PageNumber * @PageSize - @PageSize + 1 AND @PageNumber * @PageSize " StatementType="SELECT" QueryHash="0xC87751DAF17D185B" QueryPlanHash="0xA6EB5356BF62333C" RetrievedFromCache="false">

    <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />

    <QueryPlan CachedPlanSize="216" CompileTime="43" CompileCPU="42" CompileMemory="2984">

    <MemoryGrantInfo SerialRequiredMemory="512" SerialDesiredMemory="544" />

    <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="262144" EstimatedPagesCached="65536" EstimatedAvailableDegreeOfParallelism="2" />

    <RelOp AvgRowSize="647" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.137992">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    <ColumnReference Column="Expr1068" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1068" />

    <ScalarOperator ScalarString="CONVERT(money,[Expr1066],0)">

    <Convert DataType="money" Style="0" Implicit="false">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1066" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="643" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="1" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.137992">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    <ColumnReference Column="Expr1066" />

    </OutputList>

    <NestedLoops Optimized="false">

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="2" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.0633129">

    <OutputList>

    <ColumnReference Column="Expr1066" />

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1066" />

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1087],0)">

    <Convert DataType="int" Style="0" Implicit="true">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1087" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="11" EstimateCPU="1.1E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Aggregate" NodeId="3" Parallel="false" PhysicalOp="Stream Aggregate" EstimatedTotalSubtreeCost="0.0633129">

    <OutputList>

    <ColumnReference Column="Expr1087" />

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1087" />

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="false" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="9" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="4" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0633118">

    <OutputList />

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OuterReferences>

    <RelOp AvgRowSize="11" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="5" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600236">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    </OuterReferences>

    <RelOp AvgRowSize="22" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="6" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600179">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    </OuterReferences>

    <RelOp AvgRowSize="30" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="7" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600122">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    </OuterReferences>

    <RelOp AvgRowSize="34" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="8" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600065">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    </OuterReferences>

    <RelOp AvgRowSize="52" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="9" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600008">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    </OuterReferences>

    <RelOp AvgRowSize="71" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="10" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.059995">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    </OuterReferences>

    <RelOp AvgRowSize="99" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="11" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0599889">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </OuterReferences>

    <RelOp AvgRowSize="128" EstimateCPU="0.0014557" EstimateIO="0.0557176" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Index Seek" NodeId="12" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0571733" TableCardinality="131207">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OutputList>

    <IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Index="[idx_DiaList1]" Alias="[D]" TableReferenceId="2" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[@Category]">

    <Identifier>

    <ColumnReference Column="@Category" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="(0)">

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    <StartRange ScanType="GE">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[@CaratMin]">

    <Identifier>

    <ColumnReference Column="@CaratMin" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@PriceMin]">

    <Identifier>

    <ColumnReference Column="@PriceMin" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@DepthMin]">

    <Identifier>

    <ColumnReference Column="@DepthMin" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@TableMin]">

    <Identifier>

    <ColumnReference Column="@TableMin" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </StartRange>

    <EndRange ScanType="LE">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[@CaratMax]">

    <Identifier>

    <ColumnReference Column="@CaratMax" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@PriceMax]">

    <Identifier>

    <ColumnReference Column="@PriceMax" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@DepthMax]">

    <Identifier>

    <ColumnReference Column="@DepthMax" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@TableMax]">

    <Identifier>

    <ColumnReference Column="@TableMax" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </EndRange>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Dia].[FinalPrice] as [D].[FinalPrice]>=[@PriceMin] AND [TJDB].[dbo].[Dia].[FinalPrice] as [D].[FinalPrice]<=[@PriceMax] AND [TJDB].[dbo].[Dia].[Depth] as [D].[Depth]>=[@DepthMin] AND [TJDB].[dbo].[Dia].[Depth] as [D].[Depth]<=[@DepthMax] AND [TJDB].[dbo].[Dia].[Table] as [D].[Table]>=[@TableMin] AND [TJDB].[dbo].[Dia].[Table] as [D].[Table]<=[@TableMax] AND [TJDB].[dbo].[Dia].[DiaVendorID] as [D].[DiaVendorID] IS NOT NULL">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PriceMin" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PriceMax" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@DepthMin" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@DepthMax" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@TableMin" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@TableMax" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="13" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="14" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="15" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@LabIDs]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1078">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@LabIDs" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="17" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TLabID].[Val]=[TJDB].[dbo].[Dia].[LabID] as [D].[LabID]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="18" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.937E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="6.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="19" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.837E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="20" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Cuts]=(0) OR [TJDB].[dbo].[Dia].[Shape] as [D].[Shape]<>N'Round'">

    <Logical Operation="OR">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1079">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Cuts" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N'Round'" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="22" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TCut].[Val]=[TJDB].[dbo].[Dia].[Cut] as [D].[Cut]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="23" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="24" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="25" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Polishes]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1080">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Polishes" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="27" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TPolish].[Val]=[TJDB].[dbo].[Dia].[Polish] as [D].[Polish]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="28" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="29" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="30" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Symmetries]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1081">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Symmetries" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="32" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TSymmetry].[Val]=[TJDB].[dbo].[Dia].[Symmetry] as [D].[Symmetry]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="33" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="34" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="35" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Colors]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1082">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Colors" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="37" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TColor].[Val]=[TJDB].[dbo].[Dia].[Color] as [D].[Color]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="38" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="39" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="40" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Clarities]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1083">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Clarities" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="42" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TClarity].[Val]=[TJDB].[dbo].[Dia].[Clarity] as [D].[Clarity]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="43" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="44" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="45" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Fluorescences]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1084">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Fluorescences" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="47" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" TableReferenceId="2" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TFluorescence].[Val]=[TJDB].[dbo].[Dia].[FluorescenceIntensity] as [D].[FluorescenceIntensity]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="48" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1083">

    <OutputList />

    <IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Index="[PK_DiaVendor]" Alias="[DV]" TableReferenceId="2" IndexKind="Clustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Alias="[DV]" Column="ID" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Dia].[DiaVendorID] as [D].[DiaVendorID]">

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[DiaVendor].[MinDeliveryDays] as [DV].[MinDeliveryDays]>=[@MinDays] AND [TJDB].[dbo].[DiaVendor].[MinDeliveryDays] as [DV].[MinDeliveryDays]<=[@MaxDays]">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Alias="[DV]" Column="MinDeliveryDays" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@MinDays" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Alias="[DV]" Column="MinDeliveryDays" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@MaxDays" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    <RelOp AvgRowSize="639" EstimateCPU="8.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="53" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="0.0746748">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <Filter StartupExpression="false">

    <RelOp AvgRowSize="647" EstimateCPU="1E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Top" NodeId="54" Parallel="false" PhysicalOp="Top" EstimatedTotalSubtreeCost="0.0746739">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    <ColumnReference Column="Expr1032" />

    </OutputList>

    <Top RowCount="false" IsPercent="false" WithTies="false">

    <TopExpression>

    <ScalarOperator ScalarString="CASE WHEN CONVERT_IMPLICIT(bigint,[@PageNumber]*[@PageSize],0) IS NULL OR CONVERT_IMPLICIT(bigint,[@PageNumber]*[@PageSize],0)<(0) THEN (0) ELSE CONVERT_IMPLICIT(bigint,[@PageNumber]*[@PageSize],0) END">

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="OR">

    <ScalarOperator>

    <Compare CompareOp="IS">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1077">

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="MULT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageNumber" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageSize" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1077">

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="MULT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageNumber" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageSize" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1077">

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="MULT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageNumber" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageSize" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </TopExpression>

    <RelOp AvgRowSize="647" EstimateCPU="8E-08" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Compute Scalar" NodeId="55" Parallel="false" PhysicalOp="Sequence Project" EstimatedTotalSubtreeCost="0.0746738">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    <ColumnReference Column="Expr1032" />

    </OutputList>

    <SequenceProject>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1032" />

    <ScalarOperator ScalarString="row_number">

    <Sequence FunctionName="row_number" />

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp AvgRowSize="647" EstimateCPU="2E-08" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Segment" NodeId="56" Parallel="false" PhysicalOp="Segment" EstimatedTotalSubtreeCost="0.0746737">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    <ColumnReference Column="Segment1088" />

    </OutputList>

    <Segment>

    <GroupBy />

    <SegmentColumn>

    <ColumnReference Column="Segment1088" />

    </SegmentColumn>

    <RelOp AvgRowSize="639" EstimateCPU="0.000100639" EstimateIO="0.0112613" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Sort" NodeId="57" Parallel="false" PhysicalOp="Sort" EstimatedTotalSubtreeCost="0.0746737">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <MemoryFractions Input="1" Output="1" />

    <Sort Distinct="false">

    <OrderBy>

    <OrderByColumn Ascending="true">

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </OrderByColumn>

    <OrderByColumn Ascending="true">

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    </OrderByColumn>

    <OrderByColumn Ascending="true">

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    </OrderByColumn>

    </OrderBy>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Inner Join" NodeId="58" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0633118">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="59" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600236">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="60" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600179">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="61" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600122">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="62" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600065">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="63" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0600008">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="64" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.059995">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="4.18E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Left Semi Join" NodeId="65" Parallel="false" PhysicalOp="Nested Loops" EstimatedTotalSubtreeCost="0.0599889">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <NestedLoops Optimized="false">

    <OuterReferences>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </OuterReferences>

    <RelOp AvgRowSize="639" EstimateCPU="0.0014557" EstimateIO="0.0557176" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Index Seek" NodeId="66" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0571733" TableCardinality="131207">

    <OutputList>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </OutputList>

    <IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiamondID" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Lab" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CertificateNumber" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="VendorStockNumber" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasLength" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasWidth" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="MeasDepth" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMin" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleMax" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="GirdleCondition" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletSize" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="CuletCondition" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceColor" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="HasCertFile" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Index="[idx_DiaList1]" Alias="[D]" TableReferenceId="1" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="SoldOut" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[@Category]">

    <Identifier>

    <ColumnReference Column="@Category" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="(0)">

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    <StartRange ScanType="GE">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[@CaratMin]">

    <Identifier>

    <ColumnReference Column="@CaratMin" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@PriceMin]">

    <Identifier>

    <ColumnReference Column="@PriceMin" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@DepthMin]">

    <Identifier>

    <ColumnReference Column="@DepthMin" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@TableMin]">

    <Identifier>

    <ColumnReference Column="@TableMin" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </StartRange>

    <EndRange ScanType="LE">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Weight" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[@CaratMax]">

    <Identifier>

    <ColumnReference Column="@CaratMax" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@PriceMax]">

    <Identifier>

    <ColumnReference Column="@PriceMax" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@DepthMax]">

    <Identifier>

    <ColumnReference Column="@DepthMax" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="[@TableMax]">

    <Identifier>

    <ColumnReference Column="@TableMax" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </EndRange>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Dia].[FinalPrice] as [D].[FinalPrice]>=[@PriceMin] AND [TJDB].[dbo].[Dia].[FinalPrice] as [D].[FinalPrice]<=[@PriceMax] AND [TJDB].[dbo].[Dia].[Depth] as [D].[Depth]>=[@DepthMin] AND [TJDB].[dbo].[Dia].[Depth] as [D].[Depth]<=[@DepthMax] AND [TJDB].[dbo].[Dia].[Table] as [D].[Table]>=[@TableMin] AND [TJDB].[dbo].[Dia].[Table] as [D].[Table]<=[@TableMax] AND [TJDB].[dbo].[Dia].[DiaVendorID] as [D].[DiaVendorID] IS NOT NULL">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PriceMin" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FinalPrice" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PriceMax" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@DepthMin" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Depth" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@DepthMax" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@TableMin" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Table" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@TableMax" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="67" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="68" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="69" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@LabIDs]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1069">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@LabIDs" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="71" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TLabID].[Val]=[TJDB].[dbo].[Dia].[LabID] as [D].[LabID]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TLabID]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="LabID" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="72" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.937E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="6.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="73" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.837E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="74" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Cuts]=(0) OR [TJDB].[dbo].[Dia].[Shape] as [D].[Shape]<>N'Round'">

    <Logical Operation="OR">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1070">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Cuts" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Shape" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="N'Round'" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="76" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TCut].[Val]=[TJDB].[dbo].[Dia].[Cut] as [D].[Cut]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TCut]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Cut" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="77" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="78" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="79" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Polishes]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1071">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Polishes" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="81" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TPolish].[Val]=[TJDB].[dbo].[Dia].[Polish] as [D].[Polish]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TPolish]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Polish" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="82" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="83" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="84" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Symmetries]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1072">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Symmetries" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="86" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TSymmetry].[Val]=[TJDB].[dbo].[Dia].[Symmetry] as [D].[Symmetry]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TSymmetry]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Symmetry" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="87" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="88" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="89" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Colors]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1073">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Colors" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="91" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TColor].[Val]=[TJDB].[dbo].[Dia].[Color] as [D].[Color]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TColor]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Color" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="92" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="93" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="94" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Clarities]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1074">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Clarities" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="96" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TClarity].[Val]=[TJDB].[dbo].[Dia].[Clarity] as [D].[Clarity]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TClarity]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="Clarity" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="9" EstimateCPU="2E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Concatenation" NodeId="97" Parallel="false" PhysicalOp="Concatenation" EstimatedTotalSubtreeCost="1.537E-06">

    <OutputList />

    <Concat>

    <DefinedValues />

    <RelOp AvgRowSize="9" EstimateCPU="2.8E-07" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Filter" NodeId="98" Parallel="false" PhysicalOp="Filter" EstimatedTotalSubtreeCost="1.437E-06">

    <OutputList />

    <Filter StartupExpression="true">

    <RelOp AvgRowSize="9" EstimateCPU="1.157E-06" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Constant Scan" NodeId="99" Parallel="false" PhysicalOp="Constant Scan" EstimatedTotalSubtreeCost="1.157E-06">

    <OutputList />

    <ConstantScan />

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[@Fluorescences]=(0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1075">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@Fluorescences" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(0)" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    <RelOp AvgRowSize="12" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Table Scan" NodeId="101" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0">

    <OutputList />

    <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false">

    <DefinedValues />

    <Object Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" TableReferenceId="1" IndexKind="Heap" />

    <Predicate>

    <ScalarOperator ScalarString="[tempdb].[dbo].[#TFluorescence].[Val]=[TJDB].[dbo].[Dia].[FluorescenceIntensity] as [D].[FluorescenceIntensity]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#TFluorescence]" Column="Val" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="FluorescenceIntensity" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </TableScan>

    </RelOp>

    </Concat>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp AvgRowSize="11" EstimateCPU="0.0001581" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="1" LogicalOp="Clustered Index Seek" NodeId="102" Parallel="false" PhysicalOp="Clustered Index Seek" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1083">

    <OutputList />

    <IndexScan Ordered="true" ScanDirection="FORWARD" ForcedIndex="false" ForceSeek="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">

    <DefinedValues />

    <Object Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Index="[PK_DiaVendor]" Alias="[DV]" TableReferenceId="1" IndexKind="Clustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Alias="[DV]" Column="ID" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[TJDB].[dbo].[Dia].[DiaVendorID] as [D].[DiaVendorID]">

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[Dia]" Alias="[D]" Column="DiaVendorID" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[TJDB].[dbo].[DiaVendor].[MinDeliveryDays] as [DV].[MinDeliveryDays]>=[@MinDays] AND [TJDB].[dbo].[DiaVendor].[MinDeliveryDays] as [DV].[MinDeliveryDays]<=[@MaxDays]">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Alias="[DV]" Column="MinDeliveryDays" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@MinDays" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[TJDB]" Schema="[dbo]" Table="[DiaVendor]" Alias="[DV]" Column="MinDeliveryDays" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@MaxDays" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </Sort>

    </RelOp>

    </Segment>

    </RelOp>

    </SequenceProject>

    </RelOp>

    </Top>

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[Expr1032]>=CONVERT_IMPLICIT(bigint,[@PageNumber]*[@PageSize]-[@PageSize]+(1),0) AND [Expr1032]<=CONVERT_IMPLICIT(bigint,[@PageNumber]*[@PageSize],0)">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1032" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1076">

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="ADD">

    <ScalarOperator>

    <Arithmetic Operation="SUB">

    <ScalarOperator>

    <Arithmetic Operation="MULT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageNumber" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageSize" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageSize" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(1)" />

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1032" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1077">

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="true">

    <ScalarOperator>

    <Arithmetic Operation="MULT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageNumber" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@PageSize" />

    </Identifier>

    </ScalarOperator>

    </Arithmetic>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="44" StatementId="92" StatementText=" SET STATISTICS TIME OFF " StatementType="SET STATS" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="45" StatementId="93" StatementText=" DROP TABLE #TCut " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="46" StatementId="94" StatementText=" DROP TABLE #TColor " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="47" StatementId="95" StatementText=" DROP TABLE #TClarity " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="48" StatementId="96" StatementText=" DROP TABLE #TLabID " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="49" StatementId="97" StatementText=" DROP TABLE #TPolish " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="50" StatementId="98" StatementText=" DROP TABLE #TSymmetry " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    <Statements>

    <StmtSimple StatementCompId="51" StatementId="99" StatementText=" DROP TABLE #TFluorescence " StatementType="DROP OBJECT" RetrievedFromCache="true" />

    </Statements>

    </Batch>

    </BatchSequence>

    </ShowPlanXML>

  • That's not all that helpful, expecially since Management throws an error on that XML. Could you maybe just attach the saved plan rather than making someone else fix the XML, save it and reload?

    I can read the raw XML if necessary, but I really prefer not to have to.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I've already added the link in the first post, Updated the execution plan with #tables

    Please download the execution plan from here: http://files.vikasrana.com/ExecutionPlan.zip

    If required I can upload the database with only the necessary tables and stored procedure only

  • Quick thoughts:

    1. Change your splitter to the DelimitedSplit8K or DelimitedSplitN4K[/url]

    2. Read Gail's article about catch-all queries. http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

    3. Instead of using (SELECT COUNT(*) FROM #TCut), use LEN(@Cut). Applies for every similar variable.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I read Gail's article and ended up using OPTION (RECOMPILE), It reduces the execution time from 9 seconds to 4 seconds

    Can anyone please explain what exactly happened after using OPTION (RECOMPILE) ???

    Final Statistics:

    Table 'Dia'. Scan count 18, logical reads 10428, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'DiaVendor'. Scan count 9, logical reads 3419, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Final Query:

    DECLARE

    @cutVARCHAR(500) = '||Fair||Good||Very Good||Excellent||Ideal||',

    @ColorVARCHAR(500) = '||K||J||I||H||G||F||E||D||',

    @ClarityVARCHAR(500) = '||SI2||SI1||VS2||VS1||VVS2||VVS1||IF',

    @CaratMinmoney = 2,

    @CaratMaxmoney = 1800,

    @PriceMinmoney = 0,

    @PriceMaxmoney = 500000,

    @LabIDVARCHAR(500) = NULL,

    @PolishVARCHAR(500) = '||Good||Very Good||Excellent||',

    @SymmetryVARCHAR(500) = '||Good||Very Good||Excellent||',

    @DepthMinmoney = 40,

    @DepthMaxmoney = 90,

    @TableMinmoney = 40,

    @TableMaxmoney = 90,

    @FluorescenceVARCHAR(500) = '||Very Strong||Strong||Medium||Faint||N/A||',

    @CategoryVARCHAR(500) = 'Round',

    @OrderVARCHAR(20) = 'asc',

    @OrderByVARCHAR(20) = 'Shape',

    @PageNumberint = 1,

    @PageSizeint = 20,

    @MinDaysint = 0,

    @MaxDaysint = 10

    DECLARE @Cuts INT,

    @Colors INT,

    @Clarities INT,

    @LabIDs INT,

    @Polishes INT,

    @Symmetries INT,

    @Fluorescences INT

    SELECT@Cuts = ISNULL(LEN(@Cut), 0),

    @Colors = ISNULL(LEN(@Color), 0),

    @Clarities = ISNULL(LEN(@Clarity), 0),

    @LabIDs = ISNULL(LEN(@LabID), 0),

    @Polishes = ISNULL(LEN(@Polish), 0),

    @Symmetries = ISNULL(LEN(@Symmetry), 0),

    @Fluorescences = ISNULL(LEN(@Fluorescence), 0)

    IF @CaratMin < 1 OR @CaratMin IS NULL

    SELECT @CaratMin = 2

    IF @CaratMax < 1 OR @CaratMax IS NULL

    SELECT @CaratMax = 1800

    SELECT @CaratMin = @CaratMin / 100, @CaratMax = @CaratMax / 100

    IF @PriceMin < 1 OR @PriceMin IS NULL

    SELECT @PriceMin = 0

    IF @PriceMax < 1 OR @PriceMax IS NULL

    SELECT @PriceMax = 500000

    IF @DepthMin < 40 OR @DepthMin IS NULL

    SELECT @DepthMin = 40

    IF @DepthMax < 40 OR @DepthMax IS NULL

    SELECT @DepthMax = 90

    IF @TableMin < 40 OR @TableMin IS NULL

    SELECT @TableMin = 40

    IF @TableMax < 40 OR @TableMax IS NULL

    SELECT @TableMax = 90

    SET STATISTICS TIME ON

    ;WITH CTE AS

    (

    SELECT

    Row_Number() OVER(ORDER BY LabID, FinalPrice, [Weight]) RowID,

    D.*

    FROM Dia D

    INNER JOIN DiaVendor DV

    ON D.DiaVendorID = DV.ID

    WHERE SoldOut = 0

    AND DiaVendorID IS NOT NULL

    AND ISNULL(MinDeliveryDays, 5) >= @MinDays AND ISNULL(MinDeliveryDays, 1) <= @MaxDays

    AND FinalPrice >= @PriceMin

    AND FinalPrice <= @PriceMax

    AND [Weight] >= @CaratMin

    AND [Weight] <= @CaratMax

    AND Depth >= @DepthMin

    AND Depth <= @DepthMax

    AND [Table] >= @TableMin

    AND [Table] <= @TableMax

    AND SHAPE = @Category

    AND (@LabIDs = 0 OR CHARINDEX('||' + LabID + '||', @LabID, 0) > 0)

    AND (@Cuts = 0 OR Shape != 'Round' OR CHARINDEX('||' + Cut + '||', @cut, 0) > 0)

    AND (@Polishes = 0 OR CHARINDEX('||' + Polish + '||', @Polish, 0) > 0)

    AND (@Symmetries = 0 OR CHARINDEX('||' + Symmetry + '||', @Symmetry, 0) > 0)

    AND (@Colors = 0 OR CHARINDEX('||' + Color + '||', @Color, 0) > 0)

    AND (@Clarities = 0 OR CHARINDEX('||' + Clarity + '||', @Clarity, 0) > 0)

    AND (@Fluorescences = 0 OR CHARINDEX('||' + FluorescenceIntensity + '||', @Fluorescence, 0) > 0)

    )

    SELECT

    [DiamondID]

    ,[Shape]

    ,[Weight]

    ,[Color]

    ,[Clarity]

    ,[Cut]

    ,[LabID]

    ,[Lab]

    ,CAST((SELECT COUNT(*) FROM CTE) AS money) [RapNetPrice]

    ,[FinalPrice]

    ,[CertificateNumber]

    ,[VendorStockNumber]

    ,[Symmetry]

    ,[Polish]

    ,[Depth]

    ,[Table]

    ,[MeasLength]

    ,[MeasWidth]

    ,[MeasDepth]

    ,[GirdleMin]

    ,[GirdleMax]

    ,[GirdleCondition]

    ,[CuletSize]

    ,[CuletCondition]

    ,[FluorescenceColor]

    ,[FluorescenceIntensity]

    ,[HasCertFile]

    ,[DiaVendorID]

    ,[SoldOut]

    FROM CTE

    WHERE RowID BETWEEN @PageNumber * @PageSize - @PageSize + 1 AND @PageNumber * @PageSize

    OPTION (RECOMPILE)

    SET STATISTICS TIME OFF

  • From that blog post:

    The problem with these types of queries is that there is no stable plan. The optimal plan differs completely depending on what paramters are passed. The optimiser can tell that and it plays safe. It creates plans that will always work. That’s (one of the reasons) why in the first example it was an index scan, not an index seek.

    The downside of the safe plan is that it’s highly unlikely to be a good plan and, even if it is, it won’t be good for all possible combinations of plans.

    So, how to handle this type of query? Well, there are typically two ways.

    Recompile

    This is only an option on SQL 2008. On 2008, if the query is specified with the OPTION (RECOMPILE) hint, then the optimiser knows it doesn’t have to worry about safe plans because the plan will never be reused. In fact, if I add that hint to the query in the first example, I get the expected index seek.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply