I'm not a DBA. I have two servers. One of them runs on sql server 2000, the other on sql server 2014. Both have almost identical hardware (2014 has more RAM). My job is to migrate all databases and activity from the first server to the second one.
To achieve this I made database backups on SQL 2000 and restored them on a server running on SQL 2008. Then made another set of backups and restored them on the 2014 server. You can't restore 2000 backups on a 2014 server - you need an intermediary - in my case it was 2008. Anyway, now that I have all the databases on the 2014 server I began testing some stored procedures and queries. Some queries run as good as on the 2000 server. Unfortunately, there are some that take ages - what takes about 20 seconds on the SQL 2000 server, takes a couple of hours on the 2014 server which is not acceptable. I made several steps to improve the performance:
- I rebuilt/reorganized indexes
- I ran
Update Statistics table_name with FULLSCAN
- I ran
sp_updatestats
- I ran
DBCC UPDATEUSAGE('database_name') WITH COUNT_ROWS
- I altered between database compatibility levels 2014, 2012 and 2008 (2005 displays an error and there is no option to select 2000)
Nothing worked. Am I missing something? Optimizing the problematic queries is not a real option - there are too many of them - the problem needs to be addressed globally.
Example query which works fine:
select
MKPF.MANDT,
MKPF.MBLNR,
MKPF.MJAHR,
MSEG.BWART,
MSEG.MATNR,
MSEG.LGORT,
MKPF.BUDAT,
MKPF.CPUDT,
MKPF.CPUTM,
MKPF.AEDAT,
MSEG.SHKZG
from PI2.PKT.pkt.MSEG AS MSEG
join PI2.PKT.pkt.MKPF AS MKPF
on MKPF.mandt=MSEG.mandt and MKPF.MJAHR = MSEG.MJAHR and MKPF.MBLNR = MSEG.MBLNR
join PI2.PKT.pkt.MARA MARA
on MARA.MANDT=MSEG.MANDT and MARA.MATNR = MSEG.MATNR
and MARA.spart ='01'
However, when I add a WHERE
to the query it takes a couple of hours to finish instead of 20 seconds like on SQL Server 2000:
select
MKPF.MANDT,
MKPF.MBLNR,
MKPF.MJAHR,
MSEG.BWART,
MSEG.MATNR,
MSEG.LGORT,
MKPF.BUDAT,
MKPF.CPUDT,
MKPF.CPUTM,
MKPF.AEDAT,
MSEG.SHKZG
from PI2.PKT.pkt.MSEG AS MSEG
join PI2.PKT.pkt.MKPF AS MKPF
on MKPF.mandt=MSEG.mandt and MKPF.MJAHR = MSEG.MJAHR and MKPF.MBLNR = MSEG.MBLNR
join PI2.PKT.pkt.MARA MARA
on MARA.MANDT=MSEG.MANDT and MARA.MATNR = MSEG.MATNR
and MARA.spart ='01'
WHERE
MSEG.Mandt='500' and MSEG.MATNR like '00000000%' and
MKPF.CPUDT between @datefrom and @dateto
AND MSEG.BWART in ('101','561')
FYI @datefrom
and @dateto
are defined beforehand (I'm sure they don't affect the preformance). PI2
is a linked server. The linked server has the exact same properties on 2014 as it does on 2000.
Any ideas on what I should do? At this point I'm not sure whether it's an issue with the SQL Server 2014 configuration or maybe there's an issue with the linked server (maybe the linked server had a better network connection with the old sql server 2000? )