Friday, June 3, 2011

Auto Update Statistics and Auto Update Statistics Asynchronously Investigation

Below are my findings into the Auto Update Statistics and Auto Update Statistics Asynchronously database options.

What I discovered using profiler was:
Scenario 1:
  • Auto Update Statistics = True
  • Auto Update Statistics Asynchronously = False
This resulted in the relevant table statistics being updated as part of the user’s session before the user query starts retrieving data. This is the default database setting.

Scenario 2:
  • Auto Update Statistics = True
  • Auto Update Statistics Asynchronously = True
This resulted in the relevant table statistics being updated by a system session (not the user's session) after the user query has completed.

Scenario 3:
  • Auto Update Statistics = False
  • Auto Update Statistics Asynchronously = True
This resulted in no statistics being updated. This was interesting as it means that if Auto Update Statistics is set to False, it does not matter that Auto Update Statistics Asynchronously is set to True as the statistics will not be auto updated.

The code used to test this was:
-- Create the test table
CREATE TABLE [dbo].[t1](
      [c1] [bigint] IDENTITY(1,1) NOT NULL,
      [c2] [varchar](50) NULL
) ON [PRIMARY]
GO
-- Insert first data row into table
INSERT INTO dbo.t1
            (c2)
VALUES      ('x')
GO 
-- Stats are only created once you add the where clause
SELECT *
FROM   dbo.t1
WHERE  c1 < 5 
-- Use the below to show when stats were last updated
SELECT OBJECT_NAME(OBJECT_ID)          AS TABLENAME,
       NAME                            AS STATS_NAME,
       STATS_DATE(OBJECT_ID, STATS_ID) AS STATISTICS_UPDATE_DATE
FROM   SYS.STATS
WHERE  OBJECT_NAME(OBJECT_ID) = 't1' 
-- Insert several rows to the table
INSERT INTO DBO.T1
            (C2)
VALUES      ('x')
GO 1000
/*
When you run the below the stats will be updated and this is the data I captured in Profiler. Specifically the EventClasses Auto Stats, Lock:Acquired, Lock:Released, SQL:StmtStarting, SQL:StmtCompleted, Performance statistics and all columns.
*/
SELECT *
FROM   DBO.T1
WHERE  C1 > 5 

Monday, April 11, 2011

SQL Server 2008 R2 upgrade perf-ReportServer-rsctr.dll error

While performing an in place upgrade from SQL Server 2008 to SQL Server 2008 R2 I received the following perf-ReportServer-rsctr.dll error.



Process Explorer revealed that WmiPrvSE.exe was using the file.


To resolve this issue you could try stop the 'Windows Management Instrumentation' service.

Monday, April 4, 2011

Create Test Windows Clusters using Microsoft iSCSI Software Target 3.3

Creating Test Windows clusters has got a whole lot easier now that Microsoft iSCSI Software Target 3.3 is freely available to download.

It can be found here http://www.microsoft.com/downloads/en/details.aspx?FamilyID=45105d7f-8c6c-4666-a305-c8189062a0d0.

VirtualBox http://www.virtualbox.org is a good option to host your VMs as I have found this software to be the simplest and quickest way to get my Test environments built.

The iSCSI Initiator Users Guide for Windows 7 and Windows Server 2008 R2 can be found here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=00d7c33c-93cc-4449-8d5e-3fd12d820b56

Saturday, February 12, 2011

SQL Cluster Install 'Network binding order' warning

When installing SQL Server 2008 on a cluster you may get a 'Network binding order' warning.

To identify why the setup is reporting this error:
  1. Open your ..\Setup Bootstrap\Log\..\Detail.txt file
  2. Navigate to the 'Network binding order' rule section
Below shows that 'Local Area Connection* 9' was top of the list, when it should have been 'public'

The problem is that sometimes you cannot see the device or cannot get the correct order despite using http://support.microsoft.com/kb/955963.

So what can you do?
1. Run regedt32
2. Navigate to 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Linkage'
3. Right click on 'Bind' and select 'Modify'
4. Move the correct Device (identified in Detail.txt) to the top of the list and that is it.

Saturday, February 5, 2011

Using VirtualBox to resize a virtual disk

Recently I needed to resize the C drive on a Windows 2008 R2 virtual machine from its existing 10GB to 20GB.

I performed the following steps using VirtualBox v4.

1. Execute from the command prompt (Note the Virtual Machine was Powered Off)
VBoxManage modifyhd C:\VM_Test_Env\Servers\W2K8R2-04.vdi --resize 20480



2. Start the virtual machine.

3. In Disk Management – right click the C drive – select Extend Volume – follow the Wizard prompts.


You should end up with a larger C drive.

Tuesday, February 1, 2011

WinDbg & mdmp files

Often you see mdmp files in the Log folder from when SQL Server has an issue.


The below steps, which use WinDbg, may be able to assist you find the cause of the issue.

1. Download and install Microsoft .NET Framework 4 (Standalone Installer) http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=0A391ABD-25C1-4FC0-919F-B21F31AB88B7

2. Download Windows SDK http://msdn.microsoft.com/en-us/windows/bb980924


3. Install the below option


4. Open WinDbg and add path to symbol files


SRV*c:\symbols*http://msdl.microsoft.com/download/symbols


5. Open the mdmp file


6. Run !analyze -v


The FAULTING_IP field shows the instruction pointer at the time of the fault and is the most probable cause for the issue.

7. Use lmvm to get more information on the module and then search the net for issues with the object e.g. for above you would use lmvm msvcrt


 

More information on the various outputs from ‘!analyze  -v’ can be found here http://msdn.microsoft.com/en-us/library/ff560201%28v=vs.85%29.aspx 

Friday, January 28, 2011

GhostCleanupTask & Exception Error 1222

If you experience Exception Error 1222 Severity 16 State 18 with the SPID being less than 50 and the LoginName shows 'sa', then these may be generated by the GhostCleanupTask.

To verify if indeed the GhostCleanupTask is the cause, try add the EventClasses 'Exception', 'Lock:Timout' and 'SQLTransaction' as well as filter on the LoginName 'sa' in SQL Server Profiler.

As mentioned in this link http://support.microsoft.com/kb/920093 the below will stop these errors:

DBCC TRACEON (661,-1)

To re-enable the GhostCleanupTask use:

DBCC TRACEOFF (661,-1)