• KGJ-Dev (8/29/2015)


    Hi Scott thanks for the reply.

    Hi Jeff , thanks for the reply and yes, the dump table has 3 million same kind of data. I also mentioned in my thread about it. Because this is sample data that made to post on the internet. Also, i ma sorry that i ran this over VPN. that's why it took 2-3 min. after seeing your reply i ran ion the actual box and it took 26 seconds. thanks for the clue.

    Is there any way to identify which column needs index?

    Any suggestions please

    Understood on the test data. We can fix that for testing purposes but let's hold off on that and the indexes for a minute because, other than the join columns, there doesn't appear to be any criteria that would prevent a full table scan (full clustered index scan) other than the HasProcessed column of the #TestDataDump column. Here's the code that's doing the work for you according to the code you attached (everything else is setting up test data).

    insert into #TestProcessedData(IdCard,ProductName,ProductCustScore,CardNumber,CutomerName,CustomerId)

    SELECT CC.IdCard,CP.ProductName,CPS.ProductCustScore,CC.CardNumber,C.CustomerName,C.CustomerID

    from #TestDataDump TD left join #CrediCard CC on(TD.CardNumber = CC.CardNumber)

    left join #Customers C on C.CustomerID = CC.CustomerId

    LEFT join #CustomerProduct CP on TD.ProductNumber = CP.ProductNumber

    LEFT join #CustomerProductScore CPS on(CP.IdCustProduct = CPS.IdCustProduct)

    [font="Arial Black"]Where TD.HasProcessed = 0;

    [/font]

    select * from #TestProcessedData;

    Here are my questions (and you may have already stated answers for some of these but wanted to try to get them all in one spot)...

    1. Does the #TestDataDump table represent all new data or is this maintained in a real table that you keep adding to? If you keep adding to it, how often and how many rows are typically added?

    2. Are there duplicates in the real table represented by #TestDataDump table insofar as the CardNumber and and ProductNumber?

    3. What percentage of rows will have HasProcessed = 0 in the table represented by #TestDataDump?

    4. You construct the ProductNumber in your test data using N+1000, which is 100% numeric. Is the ProductNumber totally numeric or does it have non-numeric characters in it or any leading zeros?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)