Hi Im running a piece of code on a VM which takes just 1 second on our new 2012 box it takes 15 seconds.
The execution plan is exactly the same, data is cached so it is all running in memory. Query is pasted below - its legacy code and could probably be improved but none the less it runs a lot quicker on the low spec VM. I've run an extended events session and there are no waits with a duration > 0. What could possibly be the problem?
SELECT case when PATINDEX('%(%', replace(DataItem,' ','') )>0 then case when len(substring( replace(DataItem,' ',''), PATINDEX('%(%', replace(DataItem,' ','') )+1, PATINDEX('%)%', replace(DataItem,' ','') ) - PATINDEX('%(%', replace(DataItem,' ','') )-1 ) ) = 2 then substring( replace(DataItem,' ',''), PATINDEX('%(%', replace(DataItem,' ','') )+1, PATINDEX('%)%', replace(DataItem,' ','') ) - PATINDEX('%(%', replace(DataItem,' ','') )-1 ) else null end else null end LDZ FROM Commercial.commercial.[tblNGdataitems]
There are no indexes on any of the tables, other pieces of code run a lot faster on the new 2012 machine, just this piece seems to run slow.
I have SQL 2012 installed on my laptop and the code runs in 1 second so I believe it is some setting on the server that is causing a problem. How can I troubleshoot?