THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Page Free Space

See also my SQL Server technical articles on

November 2010 - Posts

  • Myth: SQL Server Caches a Serial Plan with every Parallel Plan

    Many people believe that whenever SQL Server creates an execution plan that uses parallelism, an alternative serial plan is also cached. The idea seems to be that the execution engine then decides between the parallel and serial alternatives at runtime. I’ve seen this on forums, in blogs, and even in books. In fairness, a lot of the official documentation is not as clear as it might be on the subject. In this post I will show that only a single (parallel) plan is cached. I will also show that SQL Server can execute a parallel plan on a single thread… Before diving into the demonstration, I want to quickly run through some background information about the SQL Server plan cache. Compiled Plans Queries are expensive to compile and optimize, so SQL Server uses caching to improve efficiency through plan reuse. The server optimizes an entire batch all at once, and the result is known as a compiled plan (or sometimes ‘query plan’). The dynamic management view sys.dm_exec_cached_plans contains one row for each compiled plan, with a plan_handle that uniquely identifies the compiled plan among those currently in cache (plan handles can be reused over time). This plan handle can be passed to the dynamic management function sys.dm_exec_query_plan to show the compiled plan in XML format. When displayed in Management Studio, we can click on this XML representation to view the familiar graphical plan. A compiled plan is a compile-time object – no user or runtime context is stored. You might find it helpful to think of the compiled plan as a template – or perhaps as being similar to the estimated execution plans seen in Management Studio. Execution Contexts An execution context (or ‘executable plan’) - internally known as an MXC – is generated when a compiled plan is prepared for execution. Execution contexts contain specific runtime information, for a single execution, for a single user. Read More...
  • The Case of the Missing Shared Locks

    In this post I cover a little-known locking optimization that provides a surprising answer to the question: “If I hold an exclusive lock on a row, can another transaction running at the default read committed isolation level read it?” Most people would answer ‘no’, on the basis that the read would block when it tried to acquire a shared lock. Others might respond that it depends on whether the READ_COMMITTED_SNAPSHOT database option was in effect, but let’s assume that is not the case, and we are dealing simply with the default (locking) read committed isolation level. A Surprising Answer To investigate, let’s create a test table, and add a single row: Read More...
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement