Practical SQL Performance Troubleshooting

Filed under: Download, SQL Server

DBA daily life is always hectic. They receive many issues ranging from network, performance, security, or application. I had collected many scripts and tools since couple of years ago. They are very useful for ad-hoc troubleshooting and diagnose the problem on the spot.

When I mentioned ad-hoc means the ability to locate and diagnose the problem quickly, without collecting data with SQL Profiler or Perfmon. I’m not saying that ad-hoc approach is better, but there are many situations when we just do not have enough time to collect the data while my users are screaming. The DMVs become handy tools for this purpose. It shipped since SQL Server 2005, and has been improved in 2008. I always has those DMVs in my shortcut folder, or in most cases in my thumb drive.

I had the opportunity to do demo on this topic at Singapore SQL User Group meeting last month. The response was fantastic, knowing that we have many free scripts to solve our daily problem. I promised to upload all presentation and sample codes, so here they are:


posted on: August 21st, 2010 | Add comment

SQL Server 2008 Live Migration with Hyper-V

Filed under: Download, SQL Server

Virtualization is hot, because we can consolidates disparate servers in one box. It’s easier to manage one rather than multiple physical machines. Many companies run under utilized hardware so It can be optimized with Hyper-V. However, consolidation brings another challenges: there is only one single point of failure. That’s why we need to plan a disaster recovery scenario.

Hyper-V in Windows Server 2008 R2 already supports Live Migration. It means all services and application are still accessible when the migration is happening. This is another bonus of using Hyper-V beside the consolidation and cost saving. Running SQL Server 2008 on top of live migration enabled Hyper-V gives many advantages. When the migration/failover happens, it’s still maintain user sessions and connection.

Another advantage of using Hyper-V instead of failover cluster is It can run on top of commodities hardware. I’m not saying we can use mediocre one, but a standard high performance machine should work. The most important component is storage. We need to have FAST storage. Another tips for performance is a fast network. A Gigabit switch is a must, with multiple NICs on every machine so we can isolate traffic between inter server and application.

In general, below are steps to configure SQL Server 2008 and live migration enable Hyper-V:

  1. Configure shared storage (SAN, iSCSI, etc)
  2. Connect both nodes to shared storage
  3. Install Hyper-V role and Failover Cluster in both nodes
  4. Validate cluster configuration
  5. Create a cluster
  6. Create a Virtual Machine and enable high availability for live migration
  7. Install OS and SQL Server 2008 R2 in VM

I did presentation and demos for Singapore CTU in this topic. It was a challenging task because I only had 2 machines, so I had to squeeze 4 VMs. I did not have privilege of multiple NICs so my storage server was up and down. It was a lucky timing that everything run well when I did live migration scenario. The PPT can be downloaded here:

Many thanks to Andrew who helped in Hyper-V cluster setting. He also created step by step storage and cluster configuration. It was presented for Singapore Windows UG:


posted on: June 7th, 2010 | 1 comment

How to prepare for Exam 70-432

Filed under: Certification, SQL Server

I received this question all over again during my daily jobs teaching SQL Server. I was tempted to create a guide base on my personal experience, but the time really don’t like me. Not until I received invitation to deliver short lecture for NUS student last month.

They were preparing for Exam 70-432: SQL Server  2008 Implementation and Maintenance. It is a foundation exam for SQL DBA. It test our knowledge on daily administration and a bit of development job. I wrapped up couple of important clues and tips, and compile them in PPT slides. You may download it here:


posted on: June 1st, 2010 | Add comment

Upgrading to Reporting Services 2008 R2

Filed under: SQL Server

Well now SQL Server 2008 R2 has been released, now what? I want to take advantage all of cool stuff in Reporting Services 2008 R2. The obvious thing is I have to upgrade the existing report. There are couple of upgrade path supported:

  • From SSRS 2005 to SSRS 2008 R2
  • From SSRS 2008 to SSRS 2008 R2

In either path, there are couple of methods that we can use:

  1. In-place upgrade, easy but I strongly not recommend this.
  2. Side by side by attach and detach the database. This will be my main focus in this post.
  3. Obtain report source code, convert with VS2008 and deploy to new server with R2 enabled.

First method was definitely not my choice because does not provide roll back scenario. The 3rd method is nice but it means I have to reconfigure all security settings I have done. I did the second method which is pretty easy as long as we plan carefully, and retain all report permission intact.

Preparation
I had SSRS 2005 when decided to upgrade. Make sure that it already upgraded to service pack 2. The reason is SSRS 2008 will upgrade the database schema automatically as long as it’s already SP2.

Step 1
Backup ReportServer and ReportServerTempDb from old server. Actually the first one is the most important, but just take both backup just in case :) .

 backupdb

 

Step 2
Backup encryption key from old machine. It’s needed later when we restoring the configuration on R2 machine. The key is important to prove that we are the legitimate person to perform restoration.

backupkey

Step 3
Install SSRS 2008, this can be in the same machine with different instance or separate machine. Take note that we can actually run it as a service only and still use SQL Server 2005 as a storage for ReportServerDB. I won’t explain about the installation steps because it’s not the interest of this post. I assume that most DBAs know how to do it, otherwise do your homework in search engine :) . Make sure to not configure RS during the installation because we will do it manually later.

Step 4
Restore both databases to a new machine. Actually it’s not necessary to restore it to SQL 2008 R2 storage because RS 2008 R2 supports backward compatibility. There are many cases that company just want to have a new RS R2 but still want to utilize old SQL 2005 storage, which is fine. In my case, I restore them to the same instance of SQL 2005 with SP2 because I could not get SQL 2008 one because of licensing issues. Take note that I restore them as different name for example: ReportServer2008R2 and ReportServer2008R2TempDB. This to avoid overwrite of existing RS 2005 DB. If you have separate machine you do not need to pay attention of those naming anyway.

Step 5
Configure Reporting Service 2008 R2. Open Reporting Service Configuration manager to configure virtual directory, service account, and the most important thing: connect to existing ReportServer2008R2. I won’t explain in detail about the basic configuration here, since most DBA should be familiar with it.

The one that needed attention is to connect to existing database rather than creating a new database. In my case, I connect to ReportServer2008R2 which is the one I restored earlier. And here is the magic: RS 2008 R2 will convert and upgrade all RS 2005 schema to R2 automatically. All reports and security configuration are safe inside.

r2db

r2db-2

The last thing is to restore the encryption key. We won’t able to start the service without supplying a valid key.

restoreky

Step 6
Test your server and report. Navigate to http://yourservername/reportserver to check that the service is alive. Then open http://yourservername/reports and see that all reports has been migrated to R2 :)

reportserver

reportmanager


posted on: May 31st, 2010 | Add comment

What’s hot in SQL Server 2008 R2

Filed under: Download, SQL Server

I did a presentation for Technet event at MIcrosoft Singapore about above mentioned topic. I personally very excited on BI enhancement in R2 release. Since most audiences are new in SQL Server 2008, I also presented some new core features of “R1″ before show off the R2 one.
To sum up, here are what I like from BI features in R2:

  • Shared dataset: now we can create a dataset and share them among many reports.
  • Report part: publish and reuse report component such as table, image, and layout.
  • New control in report designer such as spark lines, KPI indicator, and maps.
  • Self-service BI with PowerPivot. This guy deserves a separate post so I won’t explore in detail here.

As usual, the presentation deck is available for download from here:


posted on: April 4th, 2010 | Add comment

Optimized desktop with Windows 7

Filed under: Windows 7

It was a busy week preparing Windows 7 Launch on October 22, 2009, and I managed to squeeze my time to do Windows 7 presentation for MaxIT event. I will post more detail about Windows 7 next time. In the mean time, you can download the PPT from the event below:

Thanks to Andrew for the base material.


posted on: October 19th, 2009 | Add comment

Presenting Trend with Reporting Services

Filed under: Download, SQL Server

I posted KPI report in previous entry, something that really cool in SSRS 2008. There is another method to display a trend without much attention on number and achievements. It’s called sparklines. There are many occasions when decision maker only need to know the trend regardless of actual values. A simple visualizations can help them to grab the fact quickly.

Below is an examples of sparklines:

sparklines1

How to create a sparklines report? It is actually simple. In general, there are 3 steps:

  • Create a chart of your choice. Lines chart is a popular form. Bind it to the data of interest such as sales amount, total cost, etc.
  • Squeeze the chart as small as possible but still maintain its readability. Remove all unnecessary  details like X and Y axis, legend, series label, etc.
  • Drag and drop the chart in to data area of your report and tidy up for better presentation.

The good thing about sparklines is its dynamic behaviour. Since it is located inside data area, it follows whatever grouping setup in rows and column. The sparklines adopts to drill down report setup along with its grouping, like the following example:

collap expand

The most important thing of creating sparklines are data binding and removing unnecessary chart properties. In the following picture, the chart is bounded to Sum(SalesAmount). I removed X and Y axis and also its title. This is a straight forward task by right clicking every property and select disable or delete.

delete

The last step is to add additional column in report table for sparklines container. I use “Total Trend” as presented in the first picture, then drag and drop the chart in to column and tidy up for better visualization. What about source code?  Download sample .rdl file from here:

As usual, it needs AdventureWorksDW2008 sample database which freely available from codeplex.


posted on: August 23rd, 2009 | 1 comment

Updated SQL 2008 Slide Deck from MaxIT Event

Filed under: Download, SQL Server

I did the second presentation for MaxIT event on July 17, 2009. There are 2 topics presented: Reporting Services 2008 for morning session and Upgrading to SQL Server 2008 in the afternoon. I found several new materials so I decided to update the slide deck and additional demos. If you already downloaded the previous PPT, this is the latest update with many enhanced information specially for afternoon session.

Reporting Services 2008 PPT:

 

Upgrading to SQL Server 2008 PPT:

 

Demo source code for KPI and Reporting Services:


posted on: July 19th, 2009 | Add comment

KPI Report with Reporting Services 2008

Filed under: Download, SQL Server

Reporting Services 2008 brought many enhancements for data visualization. The queen is Gauge, which is ideal tool to create scorecard and KPI. Imagine the report popping up in front of manager with colourful and fancy indicators like this:

thermo1

Gauge is only one among many other things. Charting is more fun than ever, with many 3D effects and customizable areas. I also like new feature such as calculated series that deliver moving average report in minutes. No more complex expression to calculate median or moving average data.

Gauge also comes with many type such as radial type with speedometer style. I can display sales indicator and turn the pointer to red, yellow, or green like this:

gauge1

I did demo and discussion about this topic in Singapore SQL UG meeting on June 25, 2009. As I promised to upload my slide deck, you can grab it here:

Of course I release the source code too for deeper exploration. Apologize that I don’t have enough passion to tidy up the reports for best appearance. It is available in my skydrive:

 

All reports need AdventureWorks2008 and AdventureWorks2008DW sample, available to download from CodePlex.

Below are some pictures from the meeting:

SQLUG-25Jun 2009-06-25 006

SQLUG-25Jun 2009-06-25 009


posted on: June 26th, 2009 | 4 comments

Some Notes on SQL Server 2008 Backup compression

Filed under: SQL Server

I blogged about backup compression here, and I mentioned that the main advantages are saving space, reduced backup and restore time. After discussion with some fellow MVPs, I have to revise my statement in previous post.

Yes, backup compression saves backup and restore time only if there are enough CPU and IO resources available. This is obvious because IO is the biggest bottleneck when reading/writing backup file. Thanks to Aaron and Andrew for remind me about this fact.

However, IO bottleneck is solvable if we use fast removable storage (eSATA for example) instead of internal hard disk. With this way, we can take full advantage of compression without affecting current machine performance.

The SQL Customer Advisory team did a very comprehensive benchmark on this. Below is some screen shoot I cut and paste from their blog post:

sqlcatcompress1

sqlcatcompress2

The complete post for benchmark by SQLCAT is here

http://sqlcat.com/technicalnotes/archive/2008/04/21/tuning-the-performance-of-backup-compression-in-sql-server-2008.aspx


posted on: June 11th, 2009 | Add comment