I've had a look at this: The Same SQL Query takes longer to run in one DB than another DB under the same server but am still perplexed by this one. I've tested this on both databases, have the exact same query plan, yet on the test database this query runs in under 20ms, and on the development database, this takes over 1 minute.
Thing to note is that the test database is an IDENTICAL duplicate of the development database at this current point in time (please note slight schema changes have taken place since asking this question - please see edit for more information). The query I am running is this:
SELECT
pn.PARTNO,
LogisticsComment,
Length,
Width,
Height,
Weight
FROM [partDB] pn
INNER JOIN [storeLines] sl
ON pn.PARTNO = sl.PARTNO
INNER JOIN [storeRequests] sr
ON sl.ITEMID = sr.LINEITEMS
WHERE sr.SERIAL = 'S14566'
This is the query execution plan:
I'm at a loss as to what could be causing this. Another thing to note, that linked question has 2 million records - this query currently should be returning 26 records.
Edit: Apologies for the delay, life has a habit of throwing curveballs.
As requested, please find the XML for both the live and test systems.
Development: PasteBin link
Test: PasteBin link
And the Actual Execution Plans for both live and test systems:
Development:
Test:
Edit 2: I've done a schema compare and noticed that two of the columns that are in this query, 'TMTPARTNO' and 'LogisticsComment' have differing data types - In the test system, they are varchar(50) and nvarchar(1500) respectively, and in the live system, they are char(18) and nchar(1500). Without changing data types in the live system, I do wonder if maybe the performance impact lies in the fact that there is so many bytes being used for the 'LogisticsComment' field?