Search results matching tags 'Best Practices', 'SQL Server 2005', and 'Performance'http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&tag=Best+Practices,SQL+Server+2005,Performance&orTags=0Search results matching tags 'Best Practices', 'SQL Server 2005', and 'Performance'en-USCommunityServer 2.1 SP2 (Build: 61129.1)A Rose By Any Other Namehttp://sqlblog.com/blogs/linchi_shea/archive/2007/11/20/a-rose-by-any-other-name.aspxTue, 20 Nov 2007 20:04:00 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:3442Linchi Shea<P>Regardless of the DBMS make or model, the transaction throughput curve of a database system is often shaped like a trapezoid. As the load level goes up initially, so does the transaction throughput. As the load level continues to go up, the transaction throughput will reach a plateau. After the load level is cranked up still further, the transaction throughput will inevitably start to drop and may eventually come to a&nbsp; halt.</P>
<P>With respect to the throughput drop under severe load, two questions are interesting: (1) what is the cause of the drop? and (2) what can we do to delay the drop until an even higher load level?</P>
<P>The answers are of course dependent on the nature of the workload, the system configurations, and a host of other factors. </P>
<P>So rather than trying to address the questions in general, let's look at one specific type of tests I often perform, which is to stress the processors, memory, and their interconnect of a server with a SQL Server read-only workload that effectively caches all the data pages in memory. In other words, this workload takes the disk I/Os out of the equation.</P>
<P>As expected and with no exception, I would see the transaction throughput start to drop--sometimes rather dramatically--as I increase the load level beyond saturation. When this may happen often correlates nicely with a dramatic increase in waits on <I>Thread-safe memory objects waits</I> under <I>SQLServer:Wait Statistics</I>. Unfortunately, this wait counter is documented with a rather useless tautology in that the explanation more or less repeats what the name already suggests without adding useful information. (BTW, the explanation is "Statistics for processes waiting on thread-safe memory allocators"). So,&nbsp; from looking at the wait stats, I can't really tell what wait or waits are killing the transaction throughput.</P>
<P>The point I want to illustrate, however, is the dramatic impact of a change to the workload--a change that merely gives the stored procedures different names.</P>
<P><B>Original workload:</B> The database calls of the workload calls are even distributed between two stored procedures, spOrderStatus and spStockLevel. </P>
<P><B>Modified workload</B>: In the same database, I created 100 stored procedures: spOrderStatus_1 through spOrderStatus_100, that are identical to spOrderStatus except the names. Similarly, I created another 100 stored procedures: spStockLevel_1 through spStockLevel_100, that are identical to spStockLevel except the names. I then modified the original workload to distribute the database calls evenly among spOrderStatus_1 through spOrderStatus_100 and spStockLevel_1 through spStockLevel_100.</P>
<P>With the modified workload, the same database was able to sustain the peak throughput for significantly higher load level (i.e. more users). The following chart summarizes the throughput behavior between the original workload and the modified workload on the test server:</P>
<P><IMG src="http://sqlblog.com/blogs/linchi_shea/attachment/3442.ashx"> </P>
<P>I didn't specifically test how many identical but differently named stored procedures I had to create to see the impact on the transaction throughput. 100 for each stored procedure was picked randomly. </P>
<P>Note that this is a known technique and is used in some of the published SQL Server TPC-C tests. For instance, in the best <A href="http://www.tpc.org/tpcc/results/tpcc_result_detail.asp?id=105112801">SQL Server TPC-C results obtained on HP Superdome</A>, 32 New_Order stored procedures are created with 32 different names but identical code inside. Stored procedures with different names but identical code are also created for several other transactions.</P>
<P>So, a rose by a different name may just smell better.</P>Performance Impact: The Potential Cost of Read_Committed_Snapshothttp://sqlblog.com/blogs/linchi_shea/archive/2007/10/04/performance-impact-the-potential-cost-of-read-committed-snapshot.aspxFri, 05 Oct 2007 03:49:00 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:2883Linchi Shea<P>In response to my previous blog post--<A href="http://sqlblog.com/blogs/linchi_shea/archive/2007/10/01/performance-impact-setting-a-database-to-read-only.aspx">Performance Impact: Setting a Database to Read Only</A>, Shailesh Khanal mentioned that he observed significant performance degradation from&nbsp;READ COMMITTED SNAPSHOT OFF to ON for a read-only workload. This&nbsp;is counter intuitive since there is nothing in the version store if only SELECT statements are running, and the overhead of turning READ COMMITTED SNAPSHOT ON without maintaining any versions shouldn't be that high.</P>
<P>So I decided to conduct some tests myself with a different read-only workload on SQL Server 2005 SP2 (9.00.3042) Enterprise Edition. The read-only workload was the same as that described in&nbsp;the previous blog post--<A href="http://sqlblog.com/blogs/linchi_shea/archive/2007/10/01/performance-impact-setting-a-database-to-read-only.aspx">Performance Impact: Setting a Database to Read Only</A>.</P>
<P>My results were mixed. On one hand, I confirmed Shailesh Khanal's observation that turning READ COMMITTED SNAPSHOT ON caused significant performance degradation. It's interesting to note that performance degradation was all observed on 64-bit 16-way machines. On the other hand, I didn't always observe heavy performance penalty when turning READ COMMITTED SNAPSHOT ON. On a 32-bit 4-way machine, I didn't see any degradation at all. The following two charts summarize&nbsp;my results:</P>
<P><IMG src="http://sqlblog.com/blogs/linchi_shea/attachment/2883.ashx"> </P>
<P>In Fig 1, the performance penalty of READ_COMMITTED_SNAPSHOT&nbsp;for a read-only workload was astounding. Just by turning READ_COMMITTED_SNAPSHOT OFF, the transaction throughput gained a whopping ~60%. This was observed in repeated test runs, and on two different platforms. The common characteristics of these two platforms included: (1) the SQL Server 2005 instances were both x64 running on Windows 2003 x64, and (2) the servers&nbsp;both had 16 cores.</P>
<P>That's bad news. But there&nbsp;was good news. On a different platform, repeating the same test led to very different results as summarized in Fig 2 above. If there is any difference between the two lines in Fig 2, turning READ_COMMITTED_SNAPSHOT ON appears to have produced slightly better throughput, though the difference should probably be considered insignificant and within the margin of error. This test platform was 32-bit SQL Server 2005 running on 32-bit Windows 2003, and the server had 4 cores.</P>
<P>Now, I don't know the test environment that Shailesh Khanal used&nbsp;to obtain his results. But from my own tests,&nbsp;I'd venture a conjecture that the performance difference could be attributed to the difference between 64-bit and 32-bit, not the hardware difference between 4 cores and 16 cores. And I'd further venture to suggest that the performance degradation from READ_COMMITTED_SNAPSHOT OFF to ON in the case of 64-bit and read-only workload was most likely due to a bug because the degradation was simply too large to be a feature or by design.</P>
<P>So is there any practical significance to all this?</P>
<P>Clearly, you need to use READ_COMMITTED_SNAPSHOT with caution in performance tuning. Best practice recommends that you consider using it if contention is costing you throughput. For read-only workloads, there is no reader/writer contention for READ_COMMITTED_SNAPSHOT to help avoid, and there is no statement-level data consistency problem for it to prevent.</P>
<P>The other lesson is that you really can't assume anything, even if it intuitively makes sense. You should always confirm it through testing, if possible.</P>
<P>Finally, there could be a scenario where you have a read/write workload, and READ_COMMITTED_SNAPSHOT improves its performance by resolving your reader/write contention problem, but at the same time degrades the performance of its read-only queries. Overall, you may or may not see a net gain. Again, you'll have to run tests to be sure one way or another.</P>
<P>&nbsp;</P>