<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rob's SQL Server Blog : 2005</title><link>http://blogs.technet.com/rob/archive/tags/2005/default.aspx</link><description>Tags: 2005</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SQL Server 2005 Multi-Site Clustering with Windows Server 2008</title><link>http://blogs.technet.com/rob/archive/2009/03/15/sql-server-2005-multi-site-clustering-with-windows-server-2008.aspx</link><pubDate>Mon, 16 Mar 2009 01:12:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3213295</guid><dc:creator>robcarrol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/rob/comments/3213295.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3213295</wfw:commentRss><description>&lt;P&gt;I was working recently with a customer who was looking to deploy a SQL Server 2005 cluster across 2 geographically dispersed sites using Windows Server 2008. They were looking to utilise the new clustering improvements in Windows Server 2008 to build a highly available SQL Server solution. The customer required automatic failover between the sites in the event of a disaster, but their current solution required manual intervention by an administrator in order to failover to the disaster recovery site. Automatic failover would increase application availability, and reduce the complexity of the solution. Each site has it's own SAN storage and the customer planned to replicate data between each site using SRDF replication.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;This led me to do further research into clustering SQL Server in this type of environment. Windows Server 2008 introduces greater flexibility in the choice of Quorum configuration. The concept of quorum moves away from the requirement of a shared storage resource, but now refers to the number of votes needed to establish a majority. All nodes and a witness resource&amp;nbsp; can get a vote, which removes the disk as the single point of failure as in previous clustering models. The 4 Quorum Models available are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Node and Disk Majority &lt;/LI&gt;
&lt;LI&gt;Disk Only &lt;/LI&gt;
&lt;LI&gt;Node Majority &lt;/LI&gt;
&lt;LI&gt;Node and File Share Majority &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;As there is no shared storage between the nodes in a multi-site cluster, 2 of these Quorum models are suitable for multi-site clustering: Node Majority and Node and File Share Majority. Node and Disk Majority and Disk Only should only be used in a multi-site cluster if specifically directed by your storage vendor as your disk replication software needs to support these configurations.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Node and File Share Majority:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This allows the creation of up to 16 nodes with no shared disks. A file share acts as a witness, meaning that a 2 node cluster will have have 3 votes, so connectivity can be lost by either one of the nodes or the witness and the cluster can still continue to function. &lt;/P&gt;
&lt;P&gt;A cluster quorum configured to use a node-and-file-share majority is a great solution for multi-site clusters. The file share witness can reside at a third site independent of either site hosting a cluster node for high disaster resilience. A single file server can serve as a witness to multiple clusters (with each cluster using a separate file share witness on the file server).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_4.png" mce_href="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=image src="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_thumb_1.png" width=240 height=170 mce_src="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;This configuration gives the highest resilience as the cluster can automatically recover from the loss of any one site without manual intervention.&lt;/P&gt;
&lt;P&gt;The File Share Witness (FSW) needs to be in the sane forest as the nodes and be running Windows Server 2003 or Windows Server 2008. For maximum resilience, it is best to locate the FSW at a 3rd site separate from the cluster nodes. The FSW does not need to be attached to shared storage and should NOT be a node in the same cluster.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR&gt;Node Majority:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A node-majority cluster consists of 3 or more nodes without shared storage. Each of the nodes has a vote and there is no shared disk vote. A majority of votes are necessary to operate the cluster if 2 nodes fail in a 3 node cluster, then the remaining node drops out of the cluster. An administrator can manually over-ride this and force the remaining node to start. When the other nodes come back, majority quorum is achieved again and the cluster comes back online seamlessly.&lt;/P&gt;
&lt;P&gt;This configuration works best with an odd number of cluster nodes as it is not enough to have half the cluster nodes functioning in this model. If four nodes were set up in a node-majority configuration, the cluster would continue to operate with the loss of one node but not with the loss of two nodes. You should use an odd number of nodes with Node Majority as 4 nodes can only survive 1 failure, which is the same as 3 nodes.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_2.png" mce_href="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=image src="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_thumb.png" width=240 height=133 mce_src="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The node-majority quorum configuration can work when there is more than one cluster node at each site. Consider a multi-site cluster consisting of five nodes, three of which reside at Site A and the remaining two at Site B. With a break in connectivity between the two sites, Site A can still communicate with three nodes (which is greater than 50 percent of the total), so all of the nodes at Site A stay up. The nodes in Site B are able to communicate with each other, but no one else. Since the two nodes at Site B cannot communicate with the majority, they drop out of cluster membership. (Were Site A is to go down in this case, in order to bring up the cluster at Site B, it would require manual intervention to override the non-majority.)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_6.png" mce_href="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=image src="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_thumb_2.png" width=240 height=143 mce_src="http://blogs.technet.com/blogfiles/rob/WindowsLiveWriter/SQLServer2005GeoClusteringwithWindowsSer_14C48/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As a result, the Node Majority configuration does not give automatic failover between sites as nodes 4 and 5 cannot achieve quorum. In this situation, you would need to manually force a failover. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server Networking Considerations:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Windows Server 2008 now allows nodes in the same cluster to reside in different network subnets and communicate across network routers. &lt;STRONG&gt;However, be aware that SQL Server 2005 and 2008 still require all cluster nodes to reside in the same network subnet, so you will still need to set up virtual local area networks (VLANs) to connect geographically separated cluster nodes. &lt;/STRONG&gt;This can have some benefits with regard to client response times though, as DNS replication may impact client re-connection times in the event of a failover from one site to another. VLAN's allow DNS names to stay the same, so can increase availability.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Storage Considerations:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As there is no shared storage between the nodes in a multi-site cluster, the main consideration is how to keep the data replicated between the sites. The choice of 3rd-party replication solution is important and can have a major effect on how you deploy your cluster. As such, you should work closely with your storage vendor from an early stage in the design process.&lt;/P&gt;
&lt;P&gt;Synchronous replication results in no data loss, but requires shorter distances between nodes and higher bandwidth to avoid write latency from impacting performance. Asynchronous allows you to stretch cluster nodes across longer distances, however there is a potential for data loss in the event of a failure. Asynchronous data replication also assumes a large enough network bandwidth to keep up with data changes and does not significantly impact application performance.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Conclusion:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As data replication is key in a multi-site SQL Server cluster, work with your storage vendor from an early stage to ensure they support your cluster configuration. Multi-site clustering allows you to achieve high availability and disaster recovery, however it can be a costly and complex solution. You should evaluate your business requirements first and then decide on the best technology to meet these. It could be the case that Database Mirroring, for example, could be used to give you the required level of resilience across geographical sites.&lt;/P&gt;
&lt;P&gt;In this case, the customer chose to implement a 2-node, 3-site solution using the Node and File Share Majority quorum model, with a File Share Witness located in the 3rd site. This gives site-level resilience in the event of a disaster and also allows automatic failover between the cluster nodes without having to re-write client applications, meeting the business requirements.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Additional Resources:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=75566F16-627D-4DD3-97CB-83909D3C722B&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=75566F16-627D-4DD3-97CB-83909D3C722B&amp;amp;displaylang=en"&gt;Windows Server 2008 Multi-Site Clustering Whitepaper&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;amp;EventID=1032364834&amp;amp;CountryCode=US" target=_blank mce_href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;amp;EventID=1032364834&amp;amp;CountryCode=US"&gt;TechNet Webcast: Geographically Dispersed Failover Clustering in Windows Server 2008&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;amp;EventID=1032364842&amp;amp;CountryCode=US" target=_blank mce_href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;amp;EventID=1032364842&amp;amp;CountryCode=US"&gt;TechNet Webcast: Failover Clustering and Quorum in Windows Server 2008 Enterprise&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;953170&amp;amp;sd=rss&amp;amp;spid=2855" target=_blank mce_href="http://support.microsoft.com/default.aspx?scid=kb;en-us;953170&amp;amp;sd=rss&amp;amp;spid=2855"&gt;Support Webcast: Microsoft SQL Server 2005 Failover Clustering on Windows Server 2008&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms179530(SQL.90).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms179530(SQL.90).aspx"&gt;How to: Create a New SQL Server 2005 Failover Cluster (Setup)&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3213295" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.technet.com/rob/archive/tags/High+Availability/default.aspx">High Availability</category><category domain="http://blogs.technet.com/rob/archive/tags/Clustering/default.aspx">Clustering</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category><category domain="http://blogs.technet.com/rob/archive/tags/2008/default.aspx">2008</category></item><item><title>Updated: Support Policy for SQL Server on Virtualised Platforms</title><link>http://blogs.technet.com/rob/archive/2008/10/08/updated-support-policy-for-sql-server-on-virtualised-platforms.aspx</link><pubDate>Wed, 08 Oct 2008 18:48:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3134142</guid><dc:creator>robcarrol</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/rob/comments/3134142.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3134142</wfw:commentRss><description>&lt;P&gt;The support policy for SQL Server running on virtualised platforms has now been updated to include support for SQL Server 2005 running on Hyper-V&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.microsoft.com/?id=956893"&gt;http://support.microsoft.com/?id=956893&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Microsoft provides technical support for SQL Server 2005 and for SQL Server 2008 that are running in the following hardware virtualization environments:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Windows Server 2008 with Hyper-V&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Microsoft Hyper-V Server 2008&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Configurations that are certified through the Server Virtualization Validation Program (SVVP) &lt;A href="http://windowsservercatalog.com/svvp.aspx?svvppage=svvp.htm"&gt;http://windowsservercatalog.com/svvp.aspx?svvppage=svvp.htm&lt;/A&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;Any non-Microsoft virtualization software that is not a validated configuration through the SVVP program will be handled under the policy in the following KB article:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;A href="http://support.microsoft.com/kb/897615/"&gt;http://support.microsoft.com/kb/897615/&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The following restrictions apply to support for SQL Server products in any hardware virtualization environment: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Guest Failover Clustering is not supported in a virtual machine.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;The virtual machine must be running an operating system that is supported for the specific SQL Server version and edition and that is supported for virtualization&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;The SQL Server product must be a supported version under its current Microsoft Support Lifecycle policy &lt;A href="http://support.microsoft.com/?pr=lifecycle"&gt;http://support.microsoft.com/?pr=lifecycle&lt;/A&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3134142" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category><category domain="http://blogs.technet.com/rob/archive/tags/2008/default.aspx">2008</category><category domain="http://blogs.technet.com/rob/archive/tags/Hyper-V/default.aspx">Hyper-V</category><category domain="http://blogs.technet.com/rob/archive/tags/Support/default.aspx">Support</category></item><item><title>SQL Server 2005 Performance Dashboard</title><link>http://blogs.technet.com/rob/archive/2008/06/12/sql-server-2005-performance-dashboard.aspx</link><pubDate>Thu, 12 Jun 2008 14:25:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3069902</guid><dc:creator>robcarrol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/rob/comments/3069902.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3069902</wfw:commentRss><description>&lt;P&gt;I've had one or two requests recently to set up the Performance Dashboard reports on SQL Server so I've created this blog post to step through the process. Firstly, the Performance Dashboard was created to allow customers and support engineers to monitor the general performance characteristics of a server and investigate the cause of any performance problems that may occur. The goal of the Performance Dashboard is to reduce the time spent discovering the problem so effort can be focused on actually resolving it.&lt;/P&gt;
&lt;P&gt;The SQL Server 2005 Performance Dashboard Reports are available as a link off the &lt;A class="" href="http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/servicepacks/sp2.mspx" target=_blank mce_href="http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/servicepacks/sp2.mspx"&gt;SP2 Feature Pack (Feb 2007)&lt;/A&gt;. The Performance Dashboard reports are built on the SQL Server 2005 dynamic management views,&amp;nbsp;accessing data that is already captured by SQL Server 2005.&amp;nbsp; Consequently there is no performance impact of using the dashboard except when you actually open/refresh a report. This allows engineers and customers to go much further on a performance problem while the problem is happening. The Performance Dashboard requires SQL Server 2005 SP2 or later.&lt;/P&gt;
&lt;P&gt;Install the Dashboard by running the msi from the link above, which will install to a default location of Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard. After setup finishes, open Management Studio and connect to the server and run the SETUP.SQL script (once for each SQL instance you want to monitor). Then from Object Explorer select the server, right mouse click and choose Reports – Custom Reports and browse to find the PERFORMANCE_DASHBOARD_MAIN.RDL file. This report is the only report intended to be directly loaded from SSMS; all other reports are accessed as a drill through off of the main report. The help file, PERFDASH.CHM has details about setup and permission requirements, how each report is accessed, details about the general methodology used in the dashboard and how you can use/interpret the information on each individual report.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3069902" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category><category domain="http://blogs.technet.com/rob/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.technet.com/rob/archive/tags/Performance/default.aspx">Performance</category></item><item><title>Support Webcast: Microsoft SQL Server 2005 Failover Clustering on Windows Server 2008</title><link>http://blogs.technet.com/rob/archive/2008/05/19/support-webcast-microsoft-sql-server-2005-failover-clustering-on-windows-server-2008.aspx</link><pubDate>Mon, 19 May 2008 22:53:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3057489</guid><dc:creator>robcarrol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/rob/comments/3057489.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3057489</wfw:commentRss><description>&lt;P&gt;A new Level 300 support webcast has been scheduled for Monday the 9th of June, 10:00 AM Pacific Time. The summary of the session is as follows:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This Support WebCast focuses on how to plan, implement, and administer a Microsoft SQL Server 2005 failover cluster on Windows Server 2008. This session provides step-by-step instructions about how to install SQL Server 2005 clustered instance on a Windows Server 2008 cluster. It also discusses the options you can use to move SQL Server 2005 failover cluster from Windows Server 2003 to Windows Server 2008.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;953170&amp;amp;sd=rss&amp;amp;spid=2855"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;953170&amp;amp;sd=rss&amp;amp;spid=2855&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3057489" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.technet.com/rob/archive/tags/Clustering/default.aspx">Clustering</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category><category domain="http://blogs.technet.com/rob/archive/tags/2008/default.aspx">2008</category></item><item><title>SQL Server Locking</title><link>http://blogs.technet.com/rob/archive/2008/05/18/sql-server-waits-locks-and-blocking.aspx</link><pubDate>Sun, 18 May 2008 10:30:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3056098</guid><dc:creator>robcarrol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/rob/comments/3056098.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3056098</wfw:commentRss><description>&lt;P&gt;Locking is a mechanism used by the Microsoft SQL Server Database Engine to synchronize access by multiple users to the same piece of data at the same time.&lt;/P&gt;
&lt;P&gt;Before a transaction acquires a dependency on the current state of a piece of data, such as by reading or modifying the data, it must protect itself from the effects of another transaction modifying the same data. The transaction does this by requesting a lock on the piece of data. Locks have different modes, such as shared or exclusive. The lock mode defines the level of dependency the transaction has on the data. No transaction can be granted a lock that would conflict with the mode of a lock already granted on that data to another transaction. If a transaction requests a lock mode that conflicts with a lock that has already been granted on the same data, the instance of the Database Engine will pause the requesting transaction until the first lock is released.&lt;/P&gt;
&lt;P&gt;When a transaction modifies a piece of data, it holds the lock protecting the modification until the end of the transaction. How long a transaction holds the locks acquired to protect read operations depends on the transaction isolation level setting. All locks held by a transaction are released when the transaction completes (either commits or rolls back).&lt;/P&gt;
&lt;P&gt;Applications do not typically request locks directly. Locks are managed internally by a part of the Database Engine called the lock manager. When an instance of the Database Engine processes a Transact-SQL statement, the Database Engine query processor determines which resources are to be accessed. The query processor determines what types of locks are required to protect each resource based on the type of access and the transaction isolation level setting. The query processor then requests the appropriate locks from the lock manager. The lock manager grants the locks if there are no conflicting locks held by other transactions.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR&gt;TRANSACTION ISOLATION LEVEL&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Controls the locking and row versioning behavior of Transact-SQL statements issued by a connection to SQL Server. There are 5 levels:&lt;/P&gt;
&lt;P&gt;READ UNCOMMITTED:&lt;BR&gt;&lt;BR&gt;Statements can read rows that have been modified by other transactions but not yet committed.&lt;/P&gt;
&lt;P&gt;READ COMMITTED:&lt;/P&gt;
&lt;P&gt;Specifies that statements cannot read data that has been modified but not committed by other transactions. This prevents dirty reads. Data can be changed by other transactions between individual statements within the current transaction, resulting in nonrepeatable reads or phantom data. This option is the SQL Server default.&lt;/P&gt;
&lt;P&gt;REPEATABLE READ:&lt;/P&gt;
&lt;P&gt;Specifies that statements cannot read data that has been modified but not yet committed by other transactions and that no other transactions can modify data that has been read by the current transaction until the current transaction completes.&lt;/P&gt;
&lt;P&gt;SNAPSHOT:&lt;/P&gt;
&lt;P&gt;Specifies that data read by any statement in a transaction will be the transactionally consistent version of the data that existed at the start of the transaction.&lt;/P&gt;
&lt;P&gt;SERIALIZABLE:&lt;/P&gt;
&lt;P&gt;Statements cannot read data that has been modified but not yet committed by other transactions. No other transactions can modify data that has been read by the current transaction until the current transaction completes. Other transactions cannot insert new rows with key values that would fall in the range of keys read by any statements in the current transaction until the current transaction completes.&lt;/P&gt;
&lt;P&gt;More details on all the transaction isolation modes can be &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms173763.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms173763.aspx"&gt;found here in Books Online&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR&gt;Lock Granularity and Hierarchies&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Locking at a smaller granularity, such as rows, increases concurrency but has a higher overhead because more locks must be held if many rows are locked. Locking at a larger granularity, such as tables, are expensive in terms of concurrency because locking an entire table restricts access to any part of the table by other transactions. However, it has a lower overhead because fewer locks are being maintained.&lt;/P&gt;
&lt;P&gt;The following table shows the resources that the Database Engine can lock.&lt;/P&gt;
&lt;H3 class=subHeading&gt;&lt;!----&gt;&lt;/H3&gt;
&lt;P&gt;
&lt;TABLE class="" style="BACKGROUND-COLOR: #cccccc" width="100%" border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class=""&gt;Resource &lt;/TH&gt;
&lt;TH class=""&gt;Description &lt;/TH&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;RID&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;A row identifier used to lock a single row within a heap.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;KEY&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;A row lock within an index used to protect key ranges in serializable transactions.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;PAGE&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;An 8-kilobyte (KB) page in a database, such as data or index pages.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;EXTENT&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;A contiguous group of eight pages, such as data or index pages.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;HOBT&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;A heap or B-tree. A lock protecting an index or the heap of data pages in a table that does not have a clustered index.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;TABLE&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;The entire table, including all data and indexes.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;FILE&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;A database file.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;APPLICATION&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;An application-specified resource.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;METADATA&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Metadata locks.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;ALLOCATION_UNIT&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;An allocation unit.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;DATABASE&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;The entire database.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Lock Modes&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The Microsoft SQL Server Database Engine locks resources using different lock modes that determine how the resources can be accessed by concurrent transactions.&lt;/P&gt;
&lt;P&gt;The following table shows the resource lock modes that the Database Engine uses.&lt;/P&gt;
&lt;H3 class=subHeading&gt;&lt;!----&gt;&lt;/H3&gt;
&lt;P&gt;
&lt;TABLE class="" style="BACKGROUND-COLOR: #cccccc" width="100%" border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class=""&gt;Lock mode &lt;/TH&gt;
&lt;TH class=""&gt;Description &lt;/TH&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Shared (S)&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Used for read operations that do not change or update data, such as a SELECT statement.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Update (U)&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Used on resources that can be updated. Prevents a common form of deadlock that occurs when multiple sessions are reading, locking, and potentially updating resources later.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Exclusive (X)&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Used for data-modification operations, such as INSERT, UPDATE, or DELETE. Ensures that multiple updates cannot be made to the same resource at the same time.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Intent&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Used to establish a lock hierarchy. The types of intent locks are: intent shared (IS), intent exclusive (IX), and shared with intent exclusive (SIX).&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Schema&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Used when an operation dependent on the schema of a table is executing. The types of schema locks are: schema modification (Sch-M) and schema stability (Sch-S). &lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Bulk Update (BU)&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Used when bulk copying data into a table and the &lt;B&gt;TABLOCK&lt;/B&gt; hint is specified.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;Key-range&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P&gt;Protects the range of rows read by a query when using the serializable transaction isolation level. Ensures that other transactions cannot insert rows that would qualify for the queries of the serializable transaction if the queries were run again.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" mce_keep="true"&gt;Full details of SQL Server's lock modes &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms175519.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms175519.aspx"&gt;can be found in this article&lt;/A&gt;.&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;&lt;STRONG&gt;Lock Compatibility (Database Engine)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;Multiple transactions can acquire concurrent locks on the same resource if their lock modes are compatible. If a transaction requests a lock mode that conflicts with an existing lock, the transaction is paused until the first lock is freed. &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms186396.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms186396.aspx"&gt;For a full list of lock mode&amp;nbsp;compatibilty&amp;nbsp;see this article&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;&lt;BR&gt;&lt;STRONG&gt;Key-Range Locking&lt;!----&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;&lt;SPAN style="COLOR: darkgray"&gt;&lt;/SPAN&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;&lt;SPAN id=changeHistory&gt;&lt;/SPAN&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;Key-range locks protect a range of rows implicitly included in a record set being read by a Transact-SQL statement while using the serializable transaction isolation level. The serializable isolation level requires that any query executed during a transaction must obtain the same set of rows every time it is executed during the transaction. A key range lock protects this requirement by preventing other transactions from inserting new rows whose keys would fall in the range of keys read by the serializable transaction.&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;Key-range locking prevents phantom reads. By protecting the ranges of keys between rows, it also prevents phantom insertions into a set of records accessed by a transaction.&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;A key-range lock is placed on an index, specifying a beginning and ending key value. This lock blocks any attempt to insert, update, or delete any row with a key value that falls in the range because those operations would first have to acquire a lock on the index. For example, a serializable transaction could issue a SELECT statement that reads all rows whose key values are between &lt;B&gt;'&lt;/B&gt;AAA&lt;B&gt;'&lt;/B&gt; and &lt;B&gt;'&lt;/B&gt;CZZ&lt;B&gt;'&lt;/B&gt;. A key-range lock on the key values in the range from &lt;B&gt;'&lt;/B&gt;AAA&lt;B&gt;'&lt;/B&gt; to &lt;B&gt;'&lt;/B&gt;CZZ&lt;B&gt;'&lt;/B&gt; prevents other transactions from inserting rows with key values anywhere in that range, such as &lt;B&gt;'&lt;/B&gt;ADG&lt;B&gt;'&lt;/B&gt;, &lt;B&gt;'&lt;/B&gt;BBD&lt;B&gt;'&lt;/B&gt;, or &lt;B&gt;'&lt;/B&gt;CAL&lt;B&gt;'&lt;/B&gt;.&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;&lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms191272.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms191272.aspx"&gt;More details can be found in Books Online here&lt;/A&gt;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;&lt;STRONG&gt;&lt;BR&gt;Lock Escalation&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;Lock escalation is the process of converting many fine-grain locks into fewer coarse-grain locks, reducing system overhead while increasing the probability of concurrency contention. See the &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms184286.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms184286.aspx"&gt;Lock Escalation (Database Engine)&lt;/A&gt; chapter on BOL for full details&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;&lt;BR&gt;&lt;STRONG&gt;Dynamic Locking&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;The Microsoft SQL Server Database Engine uses a dynamic locking strategy to determine the most cost-effective locks. The Database Engine automatically determines what locks are most appropriate when the query is executed, based on the characteristics of the schema and query. For example, to reduce the overhead of locking, the optimizer may choose page-level locks in an index when performing an index scan.&lt;/P&gt;
&lt;P class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;Dynamic locking has the following advantages:&lt;/P&gt;
&lt;DIV class=MTPS_CollapsibleSection style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"&gt;
&lt;UL&gt;
&lt;LI&gt;Simplified database administration. Database administrators do not have to adjust lock escalation thresholds&lt;/LI&gt;
&lt;LI&gt;Increased performance. The Database Engine minimizes system overhead by using locks appropriate to the task&lt;/LI&gt;
&lt;LI&gt;Application developers can concentrate on development. The Database Engine adjusts locking automatically&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Displaying Locking Information (Database Engine)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Microsoft SQL Server 2005 provides several ways to get information about the &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms177475.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms177475.aspx"&gt;current locking activity in an instance of the Database Engine&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Deadlocking&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A deadlock occurs when two or more tasks permanently block each other by each task having a lock on a resource which the other tasks are trying to lock. Both transactions in a deadlock will wait forever unless the deadlock is broken by an external process. &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms177433.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms177433.aspx"&gt;More information on deadlocks and techniques to avoid them can be found in BOL.&lt;!----&gt;&lt;/A&gt;&lt;/P&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;&lt;!----&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3056098" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/2000/default.aspx">2000</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category></item><item><title>SQL Server Statistics</title><link>http://blogs.technet.com/rob/archive/2008/05/16/sql-server-statistics.aspx</link><pubDate>Fri, 16 May 2008 11:00:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3055954</guid><dc:creator>robcarrol</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.technet.com/rob/comments/3055954.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3055954</wfw:commentRss><description>&lt;P class=overview&gt;SQL Server 2005 collects statistical information about indexes and column data stored in the database. These statistics are used by the SQL Server query optimizer to choose the most efficient plan for retrieving or updating data. Good statistics allow the optimizer to accurately assess the cost of different query plans, and choose a high-quality plan. All information about a single statistics object is stored in several columns of a single row in the &lt;B&gt;sysindexes&lt;/B&gt; table, and in a statistics binary large object (&lt;B&gt;statblob&lt;/B&gt;) kept in an internal-only table. In addition, information about statistics can be found in the metadata views &lt;B&gt;sys.stats&lt;/B&gt; and &lt;B&gt;sys.indexes&lt;/B&gt;&lt;/P&gt;
&lt;P class=overview&gt;&lt;A class="" href="http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx" target=_blank mce_href="http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx"&gt;Statistics Used by the Query Optimizer in Microsoft SQL Server 2005&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=overview&gt;SQL Server 2005 has the ability to automatically create and update statistics. This feature is on by default in SQL Server 2005 and SQL Server 2000. This allows the SQL Server 2005 query optimizer to produce good query plans consistently, while keeping development and administration costs low. If you need more control over statistics creation and update to get good query plans and manage the overhead of gathering statistics, you can use manual statistics creation and update capabilities.&lt;/P&gt;
&lt;P class=overview&gt;SQL Server 2005 statistics features allow you to:&lt;/P&gt;
&lt;DIV class=overview&gt;
&lt;UL&gt;
&lt;LI&gt;Implicitly create and update statistics with the default sampling rate (in the SELECT, INSERT, DELETE, and UPDATE commands, use of a column in a query condition such as a WHERE or JOIN clause causes statistics to be created or updated if necessary when automatic statistics creation and update is enabled)&lt;/LI&gt;
&lt;LI&gt;Manually create and update statistics with any desired sampling rate, and drop statistics (CREATE STATISTICS, UPDATE STATISTICS, DROP STATISTICS, CREATE INDEX, DROP INDEX)&lt;/LI&gt;
&lt;LI&gt;Manually create statistics in bulk for all columns of all tables in a database (sp_createstats)&lt;/LI&gt;
&lt;LI&gt;Manually update all existing statistics in the database (sp_updatestats)&lt;/LI&gt;
&lt;LI&gt;List statistics objects that exist for a table or database (sp_helpstats, catalog views sys.stats, sys.stats_columns)&lt;/LI&gt;
&lt;LI&gt;Display descriptive information about statisticsobjects (DBCC SHOW_STATISTICS)&lt;/LI&gt;
&lt;LI&gt;Enable and disable automatic creation and update of statistics database-wide or for a specific table or statistics object (ALTER DATABASE options AUTO_CREATE_STATISTICS and AUTO_UPDATE_STATISTICS, sp_autostats, and the NORECOMPUTE option on CREATE STATISTICS and UPDATE STATISTICS)&lt;/LI&gt;
&lt;LI&gt;Enable and disable asynchronous automatic update ofstatistics (ALTER DATABASE option AUTO_UPDATE_STATISTICS_ASYNC)&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;
&lt;P&gt;SQL Server Management Studio allows you to graphically browse and control statistics objects within its Object Explorer view. Statistics are listed in Object Explorer in a folder underneath each table object.&lt;/P&gt;
&lt;P mce_keep="true"&gt;SQL Server 2005 maintains the following information at the table level.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Number of rows in the table or index (rows column in sys.sysindexes).&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Number of pages occupied by the table or index (dpages column in sys.sysindexes).&lt;BR&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;SQL Server 2005 collects the following statistics about table columns and stores them in a statistics object (statblob):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Time the statistics were collected.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Number of rows used to produce the histogram and density information &lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Average key length.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Single-column histogram, including the number of steps.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;A string summary, if the column contains character data. DBCC SHOW_STATISTICS output contains a column "String Index" which has the value YES if a statistics object contains a string summary.&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Use &lt;B&gt;sp_helpindex&lt;/B&gt; and &lt;B&gt;sp_helpstats&lt;/B&gt; to display the list of all statistics available for a given table. &lt;B&gt;sp_helpindex&lt;/B&gt; lists all indexes on the table, and &lt;B&gt;sp_helpstats&lt;/B&gt; lists all the statistics on the table. Each index also carries the statistical information for its columns. The statistical information created using the CREATE STATISTICS command is equivalent to the statistics built by a CREATE INDEX command on the same columns. The only difference is that the CREATE STATISTICS command uses sampling by default while the CREATE INDEX command gathers the statistics with fullscan since it has to process all rows for the index anyway.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Creating Statistics with SQL Server 2005&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;You can create statistics in SQL Server 2005 in a number of different ways, as described below.&lt;/P&gt;
&lt;P mce_keep="true"&gt;• The optimizer automatically creates single-column statistics as needed as a side effect of optimizing SELECT, INSERT, UPDATE, and DELETE statements when AUTO_CREATE_STATISTICS is enabled, which is the default setting.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;• CREATE INDEX generates the declared index in the first place, and also creates one set of statistics for the column combinations constituting the index keys (but not other included columns). CREATE STATISTICS only generates the statistics for a given column or combination of columns.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;• Use sp_createstats to create statistics for all eligible columns (all except XML columns) for all user tables in the current database. A new statistics object will not be created for columns that already have a statistics object.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;• Use dbcc dbreindex to rebuild one or more indexes for a table in the specified database.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;• In Management Studio, expand the folder under a Table object, right click the Statistics folder, and choose New Statistics.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;• Use the Database Tuning Advisor (DTA) to create indexes.&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Here is an example of a CREATE STATISTICS command on the AdventureWorks.Person.Contact table:&lt;/P&gt;
&lt;P mce_keep="true"&gt;CREATE STATISTICS FirstLast2 ON Person.Contact(FirstName,LastName)&lt;BR&gt;WITH SAMPLE 50 PERCENT&lt;/P&gt;
&lt;P&gt;Usually, statistics with default sampling are sufficient to allow good query plans to be produced. However, there may be cases when statistics with larger sample sizes may benefit query optimization, such as when the values in the given column sample are not random. Non-random samples may occur if the data is sorted or clustered. Sorting or clustering may be caused by the creation of indexes, or loading data into a heap structure that is already sorted or clustered. The most commonly used larger sample size is &lt;B&gt;fullscan &lt;/B&gt;because it gives the most accurate statistics. The price for using statistics with larger sample sizes is the time required to create the statistics.&lt;/P&gt;
&lt;P&gt;The above command creates a single two-column statistics object. In this case, the SAMPLE 50 PERCENT is ignored and a full scan is performed because the table is too small. Sampling is used primarily to avoid excessive scans of data and affects only tables and indices with 1,024 or more pages (8 MB).&lt;/P&gt;
&lt;P&gt;In SQL Server 2005, statistics are created for all indices at the index creation time. SQL Server creates single-column statistics automatically when compiling queries. These statistics are created for columns where the optimizer would otherwise have to estimate the approximate density or distribution. There are the following exceptions to this rule. Statistics may not be created automatically when (1) the database is read-only, (2) there are too many outstanding compilations in progress, and (3) the column's data type is not supported for auto stats.&lt;/P&gt;
&lt;P&gt;The automatic statistics creation function can be disabled at the database level by executing&lt;/P&gt;&lt;PRE class=codeSample&gt;ALTER DATABASE dbname SET AUTO_CREATE_STATISTICS OFF&lt;/PRE&gt;&lt;PRE class=codeSample&gt;&lt;/PRE&gt;
&lt;P&gt;It's recommended that you leave this setting ON. Only disable it if you need to do so to work around known performance issues, such as the need to specify other than the default sampling rate for some tables.&lt;/P&gt;
&lt;P&gt;By default, statistics are created by sampling the data set when executing the CREATE STATISTICS command or when the statistics are automatically created. CREATE INDEX scans the whole data set anyway; therefore, the index statistics are initially created without sampling (the equivalent of &lt;B&gt;fullscan&lt;/B&gt;). The CREATE STATISTICS command allows you to set the sample size in the WITH clause either by specifying &lt;B&gt;fullscan&lt;/B&gt; or the percentage of data or number of rows to scan. It is also possible to inherit the previous sample size when specifying WITH RESAMPLE on the UPDATE STATISTICS command.&lt;/P&gt;
&lt;P&gt;For small tables, a minimum of 8 MB of data is sampled. If a table starts small, and you sample with the default sampling rate, and thereafter use the &lt;B&gt;resample&lt;/B&gt; option when updating the statistics, you will get the equivalent of &lt;B&gt;fullscan&lt;/B&gt; even as the table grows beyond 8 MB. Avoid the use of &lt;B&gt;resample&lt;/B&gt; if you want the default sampling rate as table size varies.&lt;/P&gt;
&lt;P&gt;The &lt;B&gt;dbcc show_statistics&lt;/B&gt; command displays the sample size under the Rows Sampled heading. Statistics created automatically, or updated automatically (as described in the next section) are always generated using default sampling. The default sampling rate is a slow-growing function of the table size, which allows statistics to be gathered relatively quickly even for very large tables.&lt;/P&gt;
&lt;P&gt;SQL Server Profiler can monitor automatic statistics creation. The Auto Stats event is in the group of Performance trace events. Select also the IntegerData, Success and ObjectID columns for the Auto Stats event when defining the trace.&lt;/P&gt;
&lt;P&gt;The DROP STATISTICS command is used to drop statistics, but it is not possible to drop statistics that are a byproduct of an index. Such statistics are removed only when the index is dropped.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Maintaining Statistics in SQL Server 2005&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;After a series of INSERTs, DELETEs, and/or UPDATEs are performed on a table, the statistics may not reflect the true data distribution in a given column or index. If the SQL Server query optimizer requires statistics for a particular column in a table that has undergone substantial update activity since the last time the statistics were created or updated, SQL Server automatically updates the statistics by sampling the column values (using &lt;B&gt;auto update statistics&lt;/B&gt;). The statistics auto update is triggered by query optimization or by execution of a compiled plan, and involves only a subset of the columns referred to in the query. Statistics are updated before query compilation if AUTO_UPDATE_STATISTCS_ASYNC is OFF, and asynchronously if it is ON.&lt;/P&gt;
&lt;P mce_keep="true"&gt;When a query is first compiled, if the optimizer needs a particular statistics object, and that statistics object exists, the statistics object is updated if it is out of date. When a query is executed and its plan is in the cache, the statistics the plan depends on are checked to see if they are out of date. If so, the plan is removed from the cache and during re-compilation of the query the statistics are updated. The plan also is removed from the cache if any of the statistics it depends on have changed.&lt;/P&gt;
&lt;P&gt;SQL Server 2005 determines whether to update statistics based on changes to &lt;I&gt;column modification counters&lt;/I&gt; (&lt;B&gt;colmodctrs&lt;/B&gt;).&lt;/P&gt;
&lt;P&gt;A statistics object is considered out of date in the following cases:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The table size has gone from 0 to &amp;gt;0 rows.&lt;/LI&gt;
&lt;LI&gt;The number of rows in the table when the statistics were gathered was 500 or less, and the colmodctr of the leading column of the statistics object has changed by more than 500 since then&lt;/LI&gt;
&lt;LI&gt;The table had more than 500 rows when the statistics were gathered, and the colmodctr of the leading column of the statistics object has changed by more than 500 + 20% of the number of rows in the table when the statistics were gathered&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If the statistics object is defined on a temporary table, it is out of date as discussed above, except that there is an additional threshold for recomputation at 6 rows, with a test otherwise identical to test 2 in the previous list.&lt;/P&gt;
&lt;P&gt;Table variables do not have statistics at all.&lt;/P&gt;
&lt;P&gt;The auto update statistics feature described above may be turned off at different levels.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;On the database level, disable auto update statistics using:&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;ALTER DATABASE dbname SET AUTO_UPDATE_STATISTICS OFF&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;At the table level, disable auto update statistics using the NORECOMPUTE option of the UPDATE STATISTICS command or CREATE STATISTICS command.&lt;/LI&gt;
&lt;LI&gt;Use sp_autostats to display and change the auto update statistics setting for a table, index, or statistics object.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Re-enabling the automatic updating of statistics can be done similarly using ALTER DATABASE, UPDATE STATISTICS, or sp_autostats.&lt;/P&gt;
&lt;P&gt;Auto statistics update is always performed by sampling the index or table using the default sampling rate. To set the sampling rate explicitly, run CREATE or UPDATE STATISTICS&lt;/P&gt;
&lt;P&gt;Statistics update is covered by the same SQL Profiler event as statistics creation.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3055954" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/Database+Maintenance/default.aspx">Database Maintenance</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category></item><item><title>SQL Server and Windows Memory</title><link>http://blogs.technet.com/rob/archive/2008/05/15/sql-server-and-windows-memory.aspx</link><pubDate>Thu, 15 May 2008 17:02:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3055690</guid><dc:creator>robcarrol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/rob/comments/3055690.aspx</comments><wfw:commentRss>http://blogs.technet.com/rob/commentrss.aspx?PostID=3055690</wfw:commentRss><description>&lt;P&gt;SQL Server 2000 Enterprise Edition introduced support for the&amp;nbsp;use of Windows 2000 Address Windowing Extensions (AWE) to address 8GB of memory on Windows 2000 Advanced Server and 32GB of memory on Windows 2000 Datacentre. With AWE, SQL Server can reserve memory not in use by other applications and the OS. Each instance must statically allocate the memory it needs. AWE memory can only be used for the data cache and not for executables, drivers, DLL's, etc.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 2000 on Windows 2003/Windows 2000 Advanced Server/Windows 2000 Datacentre:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The use of /PAE and AWE allows SQL Server 2000 to use more than 4GB of RAM. Without /PAE, SQL can only use up to 3GB (with /3GB switch enabled in boot.ini). To allow AWE to use the the memory range above 16GB on Windows 2000 Datacentre, the /3GB switch &lt;STRONG&gt;must not&lt;/STRONG&gt; be enabled in the server's boot.ini file. When you allocate SQL Server AWE memory on a 32GB system, Windows 2000 may require at least 1GB memory to manage AWE.&lt;/P&gt;
&lt;P&gt;SQL Server 2000 Enterprise and Developer Editions are the only editions that can use AWE.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR&gt;USING AWE MEMORY (SQL Server 2000)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Run the database engine under a Windows account with the "lock data pages in memory" option enabled. SQL Server setup will automatically grant this permission. If you start an instance from the command prompt (sqlservr.exe), you must manually assign this permission using gpedit.msc. Set the sp_configure option AWE ENABLED and restart SQL Server.&lt;/P&gt;
&lt;P&gt;Instances of SQL Server 2000 do not dynamically manage the size of the address space when you enable AWE memory. When you enable AWE and start an instance of SQL 2000, one of the following occurs:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If sp_configure max server memory has been set and there are at least 3GB RAM free on the computer, the instance acquires the amount of memory specified in max server memory&lt;/LI&gt;
&lt;LI&gt;If the amount of memory available is less than max server memory (but more than 3GB), then the instance acquires almost all of the available memory and may leave only up to 128MB of memory free&lt;/LI&gt;
&lt;LI&gt;If max server memory has not been set and there is at least 3GB of free memory available, then the instance acquires almost all of the available memory and may leave only up to 128MB of memory free&lt;/LI&gt;
&lt;LI&gt;If there is less than 3GB of free memory available, memory is dynamically allocated and, regardless of the parameter setting for AWE ENABLED, SQL Server will run in non-AWE mode&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Evaluating Memory Usage&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Use System Monitor to obtain the correct amount of SQL Server memory usage:&lt;/P&gt;
&lt;UL&gt;
&lt;UL&gt;
&lt;LI&gt;Total Server Memory (KB)&lt;/LI&gt;
&lt;LI&gt;Select memory usage from sysperfinfo&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Running Multiple instances with AWE on SQL Server 2000&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Each instance must have a max server memory setting.&lt;/P&gt;
&lt;P&gt;Sum of max server memory values for all instances should be less than the amount of physical memory on the server. If the sum greater, some of the instances will either not start or will have less memory than is specified in max server memory.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Windows 2000 Usage Considerations:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Before configuring Windows 2000 for AWE memory:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Add the /PAE switch to boot.ini&lt;/LI&gt;
&lt;LI&gt;Add the /3GB switch to enable Windows 2000 Advanced Server and Windows 2000 Datacentre to support a 3GB virtual address space. This allows user applications to address 3 GB of virtual memory and reserves 1 GB of virtual memory for the operating system. However, if there is more than 16 GB of physical memory available on a computer, Windows 2000 needs 2 GB of virtual memory address space for system purposes and therefore can support only a 2-GB virtual address space.&lt;/LI&gt;
&lt;LI&gt;
&lt;P class=tl&gt;In order to allow AWE to use the memory range above 16 GB, be sure the /&lt;I&gt;3gb&lt;/I&gt; parameter is not in the boot.ini file. If it is, Windows 2000 will be unable to address any memory above 16 GB. When allocating SQL Server AWE memory on a 32-GB system, Windows 2000 may require at least 1 GB of available memory to manage AWE. Therefore, when starting an instance of SQL Server with AWE enabled, it is recommend you do not use the default &lt;B&gt;max server memory &lt;/B&gt;setting, but instead limit it to 31 GB or less&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=tl&gt;Using Failover Clustering:&lt;/P&gt;
&lt;P&gt;If you are using SQL Server 2000 failover clustering and AWE memory, you must ensure that the summed value of the &lt;B&gt;max server memory&lt;/B&gt; settings for all the instances is less than the lowest amount of physical RAM available on any of the servers in the failover cluster. If the failover node has less physical memory than the original node, the instances of SQL Server 2000 may fail to start or may start with less memory than they had on the original node.&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL SERVER 2005&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To enable AWE for SQL Server 2005:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Run the SQL Server account under a Windows account with "Lock Pages in Memory" permissions assigned.&lt;/LI&gt;
&lt;LI&gt;Use sp_configure to set&amp;nbsp;"awe enabled" option to 1&lt;/LI&gt;
&lt;LI&gt;The "Maximize Data Throughput for Network Application" in Control Panel must be selected.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Support for AWE is available only in the SQL Server 2005 Enterprise, Standard and developer editions and only applies to 32-bit OS's. SQL Server 2005 Analysis Services (SSAS) cannot take advantage of AWE mapped memory. If available physical memory is less than the user mode VAS, AWE cannot be used.&lt;/P&gt;
&lt;P&gt;Lock pages in memory: Prevents paging the data to virtual memory or disk. Set to OFF by default in SQL Server 2005.&lt;/P&gt;
&lt;P&gt;SQL Server 2005 Enterprise Edition can access up to 64GB of memory on Windows 2000 and Windows Server 2003.&lt;/P&gt;
&lt;P&gt;Instances of SQL Server 2005 running on Windows 2000 use static AWE memory allocation, instances running on Windows Server 2003 use dynamic AWE memory allocation.&lt;/P&gt;
&lt;P&gt;To support over 4GB of physical memory, the /PAE switch must be added to boot.ini file. If more than 16GB of physical memory, the OS needs 2GB of virtual address space for system purposes and can therefore support only a 2GB user mode virtual address space. Remove /3GB from boot.ini file in order to use this memory above 16GB.&lt;/P&gt;
&lt;P&gt;The SQL Server buffer pool can fully utilise AWE mapped memory, however only database pages can be dynamically mapped to and unmapped from SQL Server's virtual address space and take full advantage of memory allocated through AWE.&lt;/P&gt;
&lt;P&gt;AWE does not directly help supporting additional users, threads, databases, queries and other objects that permanently reside in the virtual address space.&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx" target=_blank mce_href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx"&gt;SQL Server 2005 Features Comparison&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3055690" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rob/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.technet.com/rob/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.technet.com/rob/archive/tags/Memory/default.aspx">Memory</category><category domain="http://blogs.technet.com/rob/archive/tags/2000/default.aspx">2000</category><category domain="http://blogs.technet.com/rob/archive/tags/2005/default.aspx">2005</category><category domain="http://blogs.technet.com/rob/archive/tags/32-bit/default.aspx">32-bit</category></item></channel></rss>