Sql Server 2012 slower than 2005?

℡╲_俬逩灬. 提交于 2020-01-14 05:18:12

问题


We have deployed SQL Server 2012 Enterprise and we have performance issues:

  • same data (backuped from our SQL Server 2005 Enterprise and restored on 2012)
  • test script of 3200 sql SELECT statements

We do tests using Management Studio:

  1. results as plain text
  2. results in a file

On same computer:

  1. 2005 : 15 sec, 2012 : 2 min
  2. 2005 : 14 sec, 2012 : 30 sec

Even with a more powerful computer, 2012 is still slower than 2005.

What can be wrong? The way we installed SQL Server 2012 and default parameters? The way we restored the backup? What can we do?


回答1:


My first thought when I see variations like that are to ensure that you have regenerated statistics for all of your tables. There are many scripts on the web for doing this and lots of discussion about whether to use the built-in sprocs, whether to do fullscan etc. Here is one quick and dirty script through that I would run before doing comparisons.

CREATE  PROCEDURE sp_UtilityUpdateStats AS
SET NOCOUNT ON

DECLARE @iCounter       INT
DECLARE @iCounterMax    INT

DECLARE @TableList TABLE
(
    iTable INT IDENTITY(1,1) PRIMARY KEY,
    szTableName VARCHAR(128)
)

INSERT @TableList (szTableName)
SELECT [name] FROM sysobjects
WHERE [type] = 'u'
ORDER BY [name] DESC


SET @iCounterMax = (SELECT MAX(iTable) FROM @TableList)
SET @iCounter = 0
DECLARE @szTableName VARCHAR(128)

RAISERROR(N'------STARTING sp_UtilityUpdateStats------', 10, 1) WITH LOG
WHILE @iCounter < @iCounterMax
BEGIN
    SET @iCounter = @iCounter + 1

    SELECT  @szTableName = szTableName
    FROM @TableList
    WHERE iTable = @iCounter

    RAISERROR(N'UPDATE STATISTICS YourDB.dbo.%s', 10, 1, @szTableName) WITH LOG
    EXEC ('UPDATE STATISTICS YourDB.dbo.' + @szTableName)

END
RAISERROR(N'------FINISHING sp_UtilityUpdateStats------', 10, 1) WITH LOG

SET NOCOUNT OFF
GO


来源:https://stackoverflow.com/questions/10926841/sql-server-2012-slower-than-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!