• Lynn Pettis - Tuesday, March 6, 2018 8:23 AM

    Several things looking at the execution plans.
    One, drop the (nolock) hint.  This is not a "go fast button" and could potentially cause erroneous data to be returned.
    Two are the tables nucChargeTransaction and NUCCHARGETRANSACTION the same tables? Is the join between them a self join?  If so, why?
    Three, the difference I see between dev and production is the volume of data being returned.  In dev you are returning close to 45 million rows of data for status in 'C' or 'F'.  In production, however, you are only returning 5 rows of data for status in 'C' or 'F'.

    Please post the DDL (CREATE TABLE statement) for the table(s) involved including all indexes defined.  Also, please post some sample data (no more than 10 rows of data) as INSERT statements using Table Value Constructor format, https://docs.microsoft.com/en-us/sql/t-sql/queries/table-value-constructor-transact-sql.
    Also, based on the sample data, show us what the expected results should be from the query.

    Thanks I'll post the results of the above query - yes the tables are the same. The data is pretty much identical in both environments as we restore production over the top of dev.
    This is a 3rd party application so I can't explain the why's. We could replace the underlying SP with one of our own if the performance becomes an issue (in production it takes a couple of milliseconds) but my query more relates to the difference in execution plan and would this be the result of the 2 vastly different execution times?