SQL Server 2008 Infrastructure Planning and Design Guide


The new IPD (Infrastructure Planning and Design) Guide for SQL Server 2008 was released late last month.  This guide serves as a high level review of many of the key considerations when implementing a SQL Server solution.

I worked on this paper over the last few months with fellow Solid Quality Mentors colleague Greg Low and the paper’s principal author Melissa Stowe from Microsoft.

You can download a copy of the guide at http://technet.microsoft.com/en-us/solutionaccelerators/dd408383.aspx.

—-

SQL Server Expert, Steve Abraham, holds 8 Microsoft certifications and specializes in SQL Server and .Net Framework architecture, high availability, capacity planning, development, and performance tuning, and SQL Server Recovery.

EXISTS vs. COUNT(*)


Often times I see the following query used to determine if records exist:

IF ((SELECT COUNT(*) FROM Business) > 0)

BEGIN

–Do some stuff

END

My first guess would be that SQL Server would actually perform a count of all of the records in the Business table in this instance.  It turns out that it doesn’t.  It seems that this query gets turned into:

IF EXISTS (SELECT * FROM Business)

BEGIN

–Do some stuff

END

In this case, the execution plans are identical and STATISTICS IO shows the same exact I/O.

What is interesting is that if you change the COUNT(*) query to check against anything other than 0, a full counting of the records does occur.  For example:

IF ((SELECT COUNT(*) FROM Business) > 1)

BEGIN

–Do some stuff

END

This query does execute the full SELECT COUNT(*) against the table.  You might think that it would stop after reaching the desired value (in this case 1), but apparently it does not.

—-

SQL Server Expert, Steve Abraham, holds 8 Microsoft certifications and specializes in SQL Server and .Net Framework architecture, high availability, capacity planning, development, and performance tuning.

SQL Steve’s SQL Tips – Tips from SQL Server Consultant Steve Abraham


This blog was created as a resource for the SQL Server and .NET community by SQL Server Consultant and Expert Steve Abraham.  If you have any questions about SQL Server, or data access in .NET, please let me know.  I would be happy to answer any questions.

Thanks!
SQL Steve – Steve Abraham

Sql Server Expert / SQL Server Consultant

—-

SQL Server Consultant and Expert, Steve Abraham, holds 9 Microsoft certifications and specializes in SQL Server and .Net Framework architecture, high availability, capacity planning, development, and performance tuning, and SQL Server Recovery.