<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Klaus Aschenbrenner</title>
  <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/" />
  <link rel="self" href="http://www.csharp.at/blog/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2010-09-07T09:29:41.1068951+02:00</updated>
  <author>
    <name>Klaus Aschenbrenner</name>
  </author>
  <subtitle>A life between bits &amp; bytes</subtitle>
  <id>http://www.csharp.at/blog/</id>
  <generator uri="http://www.dasblog.net" version="1.9.6264.0">DasBlog</generator>
  <entry>
    <title>Unique and non-unique non-clustered indexes on a non-unique clustered index</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,e5f7c235-f1bd-4412-ba87-5ca90ee72b3f.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,e5f7c235-f1bd-4412-ba87-5ca90ee72b3f.aspx</id>
    <published>2010-09-07T09:23:31.4200000+02:00</published>
    <updated>2010-09-07T09:29:41.1068951+02:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="SQLServer" label="SQLServer" scheme="http://www.csharp.at/blog/CategoryView,category,SQLServer.aspx" />
    <content type="html">&lt;p&gt;
In the last weblog post I have talked about the differences in unique and non-unique
non-clustered indexes on a unique clustered index. In this weblog post I want to talk
about the differences of non-clustered indexes defined on a non-unique clustered index.
As you already know from this &lt;a href="http://www.csharp.at/blog/PermaLink,guid,98d6366f-9e37-4413-8435-793129ac87cb.aspx" target="_blank"&gt;posting&lt;/a&gt;,
SQL Server handles non-unique clustered indexes internally different as unique clustered
indexes. If you define a non-unique clustered index, SQL Server adds the so called &lt;strong&gt;uniquifier&lt;/strong&gt; to
your index records, which leads to a 4 byte overhead per each index row in the navigation
structure of your clustered index. 
&lt;/p&gt;
&lt;p&gt;
The following listing creates again our customers table, defines this time a non-unique
clustered index on it, and finally two non-clustered indexes, where one of them is
unique and the other is non-unique. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a table
with 393 length + 7 bytes overhead = 400 bytes 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Therefore
20 records can be stored on one page (8.096 / 400) = 20,24 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; Customers 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerID &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerName &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerAddress &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; Comments &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;189&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO 
&lt;br&gt;
&lt;/span&gt; 
&lt;br&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a non
unique clustered index on the previous created table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;CLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_Customers &lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerID&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO 
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Insert
80.000 records 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DECLARE&lt;/span&gt; @i &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 1 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;WHILE &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: gray"&gt;&lt;=&lt;/span&gt; 20000&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;BEGIN 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;DECLARE&lt;/span&gt; @j &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 1 &lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; @i&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@j &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;SET&lt;/span&gt; @j &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1&lt;span style="color: gray"&gt;; 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; @i&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@j &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: red"&gt; 'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: red"&gt;'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;SET&lt;/span&gt; @j &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1&lt;span style="color: gray"&gt;; 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; @i&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@j &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;SET&lt;/span&gt; @j &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1&lt;span style="color: gray"&gt;; 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; @i&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@j &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;SET&lt;/span&gt; @i &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;END 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a unique
non clustered index on the clustered table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;UNIQUE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_UniqueNCI_CustomerID 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerName&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO 
&lt;br&gt;
&lt;/span&gt; 
&lt;br&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a non-unique
non clustered index on the clustered table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_NonUniqueNCI_CustomerID 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerName&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
When you now do a short look into the &lt;strong&gt;sys.dm_db_index_physical_stats&lt;/strong&gt; DMV,
you can see that the unique non-clustered index takes 107 bytes per index row in the
navigation levels, where the non unique non-clustered index takes 117 bytes on the
average (minimum 111 bytes, maximum 117 bytes). Let's analyze the differences and
dump out the index root page of the unique non-clustered index through the &lt;strong&gt;DBCC
PAGE&lt;/strong&gt; command: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;NonUniqueClusteredIndexStructure_NonClusteredIndex&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 4529&lt;span style="color: gray"&gt;,&lt;/span&gt; 3&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
As you can see from the following picture SQL Server only stores the unique non-clustered
key in the index root level (and also in the intermediate levels), because the non-clustered
key is already unique by itself: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_thumb.png" width="389" height="218"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
When you examine the byte by byte representation of the unique non-clustered index
record, you can see that SQL Server uses here the following bytes: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
1 Byte: Status Bits 
&lt;li&gt;
n Bytes: Unique Non-Clustered Index Key – in this case 100 bytes 
&lt;li&gt;
4 Bytes: PageID 
&lt;li&gt;
2 Bytes: FileID 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
When you dump out the leaf-level of the unique non-clustered index, you can see that
SQL Server points through the non-unique clustered key and the uniquifier to the correct
record in the clustered table: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_thumb_1.png" width="400" height="218"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The conclusion here is that the unique non-clustered index on a non-unique clustered
index makes only the 4 byte overhead in the leaf level of the clustered index, because
here SQL Server directly points to the correct record. There is no additional overhead
involved in the non-leaf levels of the unique non-clustered index. 
&lt;/p&gt;
&lt;p&gt;
Let's now dump out the index root page of the non-unique non-clustered index defined
on our non-unique clustered index: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_thumb_2.png" width="515" height="147"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
This is now a really interesting output! The key of the index record must be by design
unique. How can SQL Server make a non-unique non-clustered index key unique? Easy
- SQL Server just adds the clustered index key (4 bytes). But the clustered index
key is also not unique by default, therefore SQL Server also adds the uniquifier (4
bytes), so you have an resulting overhead of 8 bytes per index row, when the uniquifier
is not equal to 0. When the uniquifier is equal to 0, you get an overhead of 4 bytes,
because in this case the uniquifier is not stored physically in the index record,
and a 0 is assumed by SQL Server automatically. When you again analyze the byte by
byte representation you can see the following bytes: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
1 Byte: Status Bits 
&lt;li&gt;
n Bytes: Unique Non-Clustered Index Key – in this case 100 bytes 
&lt;li&gt;
n Bytes: Non-Unique Clustered Index Key – in this case 4 bytes 
&lt;li&gt;
4 Bytes: PageID 
&lt;li&gt;
2 Bytes: FileID 
&lt;li&gt;
4 Bytes: Some bytes used by the uniquifier 
&lt;li&gt;
4 Bytes: The uniquifier value itself, when it is not equal to 0 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The minimum length of the index record is therefore 111 bytes and the maximum length
is 117 bytes already found out earlier through the &lt;strong&gt;sys.dm_db_index_physical_stats&lt;/strong&gt; DMV.
When you finally dump out the leaf-level of the non-unique non-clustered index, you
get the following result: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_84EF/image_thumb_3.png" width="465" height="169"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see the leaf-level is the same as the leaf-level in a unique non-clustered
index defined on a non unique clustered index. The leaf level just points through
the clustered key (&lt;strong&gt;CustomerID&lt;/strong&gt;) and the uniquifier to the correct
record in the clustered table. This example has shown you that there is huge overhead
(8 bytes per index row) when you define a non-unique non-clustered index on a non-unique
clustered index, because SQL Server must make the non-clustered index records internally
unique and needs therefore several bytes of storage overhead. You can download the
T-SQL script for this posting &lt;a href="http://www.csharp.at/Downloads/SQL/NUCI.zip" target="_blank"&gt;here&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
-Klaus
&lt;/p&gt;
&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;"&gt;
&lt;iframe src="http://www.facebook.com/widgets/like.php?href=http://www.csharp.at/blog/PermaLink,guid,e5f7c235-f1bd-4412-ba87-5ca90ee72b3f.aspx" scrolling="no" frameborder="0" style="border:none; width:450px; height:20px"&gt;
&lt;/iframe&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=e5f7c235-f1bd-4412-ba87-5ca90ee72b3f" /&gt;</content>
  </entry>
  <entry>
    <title>Unique and non-unique non-clustered indexes on a unique clustered index</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,4ee5bcc5-7340-4262-9fc2-73773c7f5720.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,4ee5bcc5-7340-4262-9fc2-73773c7f5720.aspx</id>
    <published>2010-08-31T18:38:26.5290000+02:00</published>
    <updated>2010-09-04T10:57:33.3727608+02:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="SQLServer" label="SQLServer" scheme="http://www.csharp.at/blog/CategoryView,category,SQLServer.aspx" />
    <content type="html">&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;In the last weblog
post I have talked about the difference of unique and non-unique clustered indexes.
As you have seen SQL Server uses an internal overhead of 4 bytes (the so-called uniquifier)
to make non-unique clustered index rows unique. Today I want to work out the difference
between unique and non-unique non-clustered indexes defined on a table with a unique
clustered index. As you already know SQL Server creates a unique clustered index when
you define the &lt;strong&gt;PRIMARY KEY&lt;/strong&gt; constraint on a table. On the other hand
you can use the &lt;strong&gt;CREATE UNIQUE CLUSTERED INDEX&lt;/strong&gt; statement to create
a unique clustered index on a table. The following listing creates our customers table,
creates a unique clustered index on it, and finally creates one unique- and one non-unique
non-clustered index on that table. &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a table
with 393 length + 7 bytes overhead = 400 bytes 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Therefore
20 records can be stored on one page (8.096 / 400) = 20,24 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; Customers 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerID &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerName &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerAddress &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; Comments &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;189&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a unique
clustered index on the previous created table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;UNIQUE&lt;/span&gt; &lt;span style="color: blue"&gt;CLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_Customers &lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerID&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Insert 80.000
records 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DECLARE&lt;/span&gt; @i &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 1 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;WHILE &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: gray"&gt;&lt;=&lt;/span&gt; 80000&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;BEGIN 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; @i&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;SET&lt;/span&gt; @i &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;END 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a unique
non clustered index on the clustered table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;UNIQUE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_UniqueNCI_CustomerID 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerName&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a non-unique
non clustered index on the clustered table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_NonUniqueNCI_CustomerID 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerName&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt;&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;After the creation
of both non-clustered indexes you can use the DMV &lt;strong&gt;sys.dm_db_index_physical_stats&lt;/strong&gt; to
get some information about the indexes. When you look into the DMV, you can see that
the unique non-clustered index has a record length of 107 bytes and the non-unique
non-clustered index has a record length of 111 bytes. So again, there must be a difference
in the internal storage format of both indexes! Let's analyze it and start with the
unique non-clustered index. &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;In my case the index
root page of the unique non-clustered index is 4370, so I can dump it out very easily
with the &lt;strong&gt;DBCC IND&lt;/strong&gt; command: &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;UniqueClusteredIndexStructure_NonClusteredIndex&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 4370&lt;span style="color: gray"&gt;,&lt;/span&gt; 3&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt;&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;As you can see from
the following figure each index record contains the non-clustered key (which is unique
in this case) – the column &lt;strong&gt;CustomerName&lt;/strong&gt;: &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_10691/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_10691/image_thumb.png" width="307" height="189"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;When you examine
the byte by byte representation of the unique non-clustered index record, you can
see that SQL Server uses here the following bytes: &lt;/span&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;1 Byte: Status Bits &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;n Bytes: Unique Non-Clustered
Index Key – in this case 100 bytes &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;4 Bytes: PageID &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;2 Bytes: FileID &lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;In sum SQL Server
uses the above mentioned 107 bytes per each index record on each non-leaf level of
the unique non-clustered index. So again, the length of your non-clustered index key
has an impact on how many rows SQL Server can store on an index page. So a &lt;strong&gt;CHAR(100)&lt;/strong&gt; –
like in this example – would be not a very good idea… &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;When you are walking
down the unique non-clustered index until you reach the leaf-level of the index always
stores the above mentioned 107 bytes per each index row – nothing more. When you finally
dump out the leaf-level of the non-clustered index, you get the following picture: &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_10691/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_10691/image_thumb_1.png" width="280" height="264"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;As you can see here,
SQL Server stores here at the leaf-level directly the clustered key – in our case
the value of the column &lt;strong&gt;CustomerID&lt;/strong&gt;. This value is for SQL Server
the pointer to the corresponding record in the clustered index. With this value in
the hand, SQL Server can now find the record in the clustered index – through a &lt;strong&gt;Clustered
Index Seek&lt;/strong&gt; operator. This is a big difference compared to non-clustered indexes
defined on a heap table. Because in a heap table, SQL Server uses at the leaf-level
the &lt;strong&gt;HEAP RID&lt;/strong&gt; to point &lt;em&gt;DIRECTLY&lt;/em&gt; to the corresponding data
page where the record is stored. Therefore SQL Server can directly read the correct
data page without accessing an additional index! &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;This also implies
that SQL Server can find a record through a non-clustered index on a heap table faster
than a record through a non-clustered index on a clustered table, because SQL Server
don't have to execute the additional &lt;strong&gt;Clustered Index Seek&lt;/strong&gt; operator.
So the correct row can be found with less page reads on a heap table. But please don't
over estimate this detail, and think that you will get a performance benefit by using
non-clustered indexes on heap tables. The fact is that SQL Server always tries to
store the index pages in the Buffer Manager, so it's really very cheap for SQL Server
to do this additional &lt;strong&gt;Clustered Index Seek&lt;/strong&gt; to get the correct record
from the clustered index back. &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;Let's now analyze
our non-unique non-clustered index. When you dump out the index root page, you can
see that SQL Server stores here the non-clustered index key and also the clustered
index key, which is different from the previous example with the unique non-clustered
index: &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_10691/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/Uniqueandnonuniquenonclusteredindexesona_10691/image_thumb_2.png" width="376" height="195"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;SQL Server needs
here the unique clustered index key to make each non-unique non-clustered index key
unique. This behavior is done on &lt;em&gt;EACH LEVEL&lt;/em&gt; of the non-unique non-clustered
index, from the index root page down to the leaf-level. This means that you have a
huge storage overhead, because SQL Server stores in &lt;em&gt;EACH INDEX RECORD&lt;/em&gt; also
your unique clustered key besides the non-unique non-clustered index key. So when
you have a badly chosen clustered key (like &lt;strong&gt;CHAR(100)&lt;/strong&gt;, etc.) it will
even get much more worse for you! When you analyze the index row you can see that
SQL Server uses the following bytes for the storage: &lt;/span&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;1 Byte: Status Bits &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;n Bytes: Non-unique
Non-Clustered Index Key – in this case 100 bytes &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;n Bytes: Unique Clustered
Index Key – in this case 4 bytes for the integer value &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;4 Bytes: PageID &lt;/span&gt; 
&lt;li&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;2 Bytes: FileID &lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;When you sum up those
bytes, you will get the 111 bytes mentioned earlier. So please keep this additional
storage overhead in your head when using non-unique non-clustered indexes, because
it impacts your non-clustered indexes on each level! You can download the T-SQL script
for this posting &lt;a href="http://www.csharp.at/downloads/SQL/UCI.zip"&gt;here&lt;/a&gt;.&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color: black; font-size: 8pt"&gt;&lt;span style="font-family: verdana"&gt;In the
next installment of this series we will have finally a look into the differences of
unique/non-unique non-clustered indexes defined on a non-unique clustered index. Stay
tuned &lt;/span&gt;&lt;span style="font-family: wingdings"&gt;J&lt;/span&gt;&lt;span style="font-family: verdana"&gt; &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: verdana; color: black; font-size: 8pt"&gt;-Klaus&lt;/span&gt;
&lt;/p&gt;
&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;"&gt;
&lt;iframe src="http://www.facebook.com/widgets/like.php?href=http://www.csharp.at/blog/PermaLink,guid,4ee5bcc5-7340-4262-9fc2-73773c7f5720.aspx" scrolling="no" frameborder="0" style="border:none; width:450px; height:20px"&gt;
&lt;/iframe&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=4ee5bcc5-7340-4262-9fc2-73773c7f5720" /&gt;</content>
  </entry>
  <entry>
    <title>SQLdays 2010 &amp;ndash; Fachkonferenz rund um SQL Server &amp;amp; Business Intelligence</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,a6af6d33-3e85-43cb-8df5-66a7d7d5be7a.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,a6af6d33-3e85-43cb-8df5-66a7d7d5be7a.aspx</id>
    <published>2010-08-30T12:10:07.5800000+02:00</published>
    <updated>2010-08-30T12:12:56.2947446+02:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.csharp.at/blog/CategoryView,category,Conferences.aspx" />
    <category term="SQL Server" label="SQL Server" scheme="http://www.csharp.at/blog/CategoryView,category,SQL%2BServer.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <i>19.-20. Oktober 2010, Rosenheim</i>
        <p>
          <em>
          </em>
        </p>
        <p>
          <b>SQL<i>days</i></b>
          <i>
          </i>ist die Konferenz für die deutschsprachige SQL Server
Community vom <b>19.-20. Oktober 2010</b> in Rosenheim. Freuen Sie sich auf <b>drei
parallele Tracks</b> mit über <b>20 Sessions</b><b>zu SQL Server Administration,
Entwicklung und Business Intelligence</b>. Treffen Sie Datenbank- und BI-Experten
wie Klaus Aschenbrenner, Markus Raatz, Steffen Krause, Thomas Grohser oder Willfried
Färber persönlich und erfahren Sie News aus erster Hand und wertvolle Tipps und Tricks
aus der Praxis. In <b>ganztägigen Workshops</b> vor und nach der Konferenz haben Sie
zudem die Gelegenheit spezielle Themen nochmal bis ins Detail zu vertiefen. 
</p>
        <p>
Sichern Sie sich jetzt Ihre Teilnahme unter <a href="http://www.SQLdays.net">www.SQL<i>days</i>.net</a></p>
        <div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;">
          <iframe src="http://www.facebook.com/widgets/like.php?href=http://www.csharp.at/blog/PermaLink,guid,a6af6d33-3e85-43cb-8df5-66a7d7d5be7a.aspx" scrolling="no" frameborder="0" style="border:none; width:450px; height:20px">
          </iframe>
        </div>
        <img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=a6af6d33-3e85-43cb-8df5-66a7d7d5be7a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Unique/Non-Unique Clustered Indexes</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,98d6366f-9e37-4413-8435-793129ac87cb.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,98d6366f-9e37-4413-8435-793129ac87cb.aspx</id>
    <published>2010-08-19T14:01:48.7180000+02:00</published>
    <updated>2010-09-04T10:58:02.3251446+02:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="SQLServer" label="SQLServer" scheme="http://www.csharp.at/blog/CategoryView,category,SQLServer.aspx" />
    <content type="html">&lt;p&gt;
In the last blog post I have talked about unique/non-unique clustered indexes on a &lt;strong&gt;heap
table&lt;/strong&gt;. A table without a clustered index is called a heap table in SQL Server.
When you define a clustered index on such a table, the table data gets structured
and is therefore referred as &lt;strong&gt;clustered table&lt;/strong&gt;. In this blog post I
want to talk about the differences in unique and non-unique clustered indexes, and
what are the storage impacts between those 2 types of clustered indexes. 
&lt;/p&gt;
&lt;p&gt;
As a prerequisite I assume that you have a basic understanding of clustered indexes,
and that you know the difference between heap and clustered tables, and how your data
pages are structured when a clustered index is defined on a table. 
&lt;/p&gt;
&lt;p&gt;
Let's start by looking on a unique clustered index. With SQL Server you have several
possibilities to define a unique clustered index. The first way – the easy one – is
to define a &lt;strong&gt;PRIMARY KEY&lt;/strong&gt; constraint on a column. SQL Server enforces
this &lt;strong&gt;PRIMARY KEY&lt;/strong&gt; constraint through the creation of a unique clustered
index on that table and that column. The another option is to create a unique clustered
index through the &lt;strong&gt;CREATE CLUSTERED INDEX&lt;/strong&gt; statement – but when you
don't specify the &lt;strong&gt;UNIQUE&lt;/strong&gt; property, SQL Server will create a non-unique
clustered index by default for you! The following code fragment creates the &lt;strong&gt;Customers&lt;/strong&gt; table
that you already know from the previous blog posting, but this time we create a &lt;strong&gt;PRIMARY
KEY&lt;/strong&gt; constraint on the column &lt;strong&gt;CustomerID&lt;/strong&gt;. Therefore SQL Server
creates a unique clustered index on that table and sorts the data pages in the leaf
level according the values in the column &lt;strong&gt;CustomerID&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: green"&gt;--
Create a table with 393 length + 7 bytes overhead = 400 bytes&lt;br&gt;
-- Therefore 20 records can be stored on one page (8.096 / 400) = 20,24&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; Customers&lt;br&gt;
&lt;span style="color: gray"&gt;(&lt;br&gt;
&lt;/span&gt; CustomerID &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL&lt;/span&gt; &lt;span style="color: blue"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue"&gt;KEY&lt;/span&gt; &lt;span style="color: blue"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;1&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt; CustomerName &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL,&lt;br&gt;
&lt;/span&gt; CustomerAddress &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL,&lt;br&gt;
&lt;/span&gt; Comments &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;189&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL&lt;br&gt;
)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;GO&lt;br&gt;
&lt;/span&gt;&lt;span style="color: green"&gt;
&lt;br&gt;
-- Insert 80.000 records&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;DECLARE&lt;/span&gt; @i &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 1&lt;br&gt;
&lt;span style="color: blue"&gt;WHILE &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: gray"&gt;&lt;=&lt;/span&gt; 80000&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;BEGIN&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt; INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; (&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; )&lt;br&gt;
&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: blue"&gt; SET&lt;/span&gt; @i &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1&lt;br&gt;
&lt;span style="color: blue"&gt;END&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
After we have identified the index root page (through the use of the &lt;strong&gt;DBCC
IND&lt;/strong&gt; command), we can dump out that page with the &lt;strong&gt;DBCC PAGE&lt;/strong&gt; command.
In my case the index root page is 775: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;UniqueClusteredIndexStructure&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 775&lt;span style="color: gray"&gt;,&lt;/span&gt; 3&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;GO&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see from the following figure each index record contains the clustered
key, in this case the value of the column &lt;strong&gt;CustomerID&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueNonUniqueClusteredIndexes_C59B/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueNonUniqueClusteredIndexes_C59B/image_thumb.png" width="426" height="240"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
When you examine the byte by byte representation of a clustered index record, you
can see that SQL Server uses here the following bytes: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
1 byte: Status Bits 
&lt;li&gt;
n bytes: Clustered Key – in this case 4 bytes 
&lt;li&gt;
4 bytes: PageID 
&lt;li&gt;
2 bytes: FileID 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
As you can see the length of the clustered key has a direct relationship of the length
of an index record. This mean as smaller your clustered key is, the more index record
can be put onto an index page, and therefore your clustered index will be much more
compact and will perform faster and are easier to maintain. When you walk down your
clustered index you will see that all intermediate levels have the same storage format
as described above. There are no differences on each level, expect the index leaf
level, because this level contains your actual logically ordered data pages. 
&lt;/p&gt;
&lt;p&gt;
Let's have now a look onto non-unique clustered indexes in SQL Server and how they
differ from unique clustered indexes. To demonstrate this kind of indexes, I have
just recreated the &lt;strong&gt;Customers&lt;/strong&gt; table and created a non-unique clustered
index on that table through the &lt;strong&gt;CREATE CLUSTERED INDEX&lt;/strong&gt; statement: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: green"&gt;--
Create a table with 393 length + 7 bytes overhead = 400 bytes&lt;br&gt;
-- Therefore 20 records can be stored on one page (8.096 / 400) = 20,24&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; Customers&lt;br&gt;
&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;CustomerID &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL,&lt;br&gt;
&lt;/span&gt; CustomerName &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL,&lt;br&gt;
&lt;/span&gt; CustomerAddress &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL,&lt;br&gt;
&lt;/span&gt; Comments &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;181&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL&lt;br&gt;
)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;GO&lt;br&gt;
&lt;/span&gt;&lt;span style="color: green"&gt;
&lt;br&gt;
-- Create a non unique clustered index&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;CLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; idx_Customers_CustomerID&lt;br&gt;
&lt;span style="color: blue"&gt;ON&lt;/span&gt; Customers&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerID&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;GO&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Finally I have inserted 80.000 records, where the column &lt;strong&gt;CustomerID&lt;/strong&gt; (the
clustered key) is not unique anymore: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: green"&gt;--
Insert 80.000 records&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;DECLARE&lt;/span&gt; @i &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 1&lt;br&gt;
&lt;span style="color: blue"&gt;WHILE &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: gray"&gt;&lt;=&lt;/span&gt; 20000&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;BEGIN&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt; INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; (&lt;br&gt;
&lt;/span&gt; @i&lt;span style="color: gray"&gt;,&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; )&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color: blue"&gt; INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; (&lt;br&gt;
&lt;/span&gt; @i&lt;span style="color: gray"&gt;,&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; )&lt;/span&gt;
&lt;/p&gt;
&lt;span style="color: blue"&gt; INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; (&lt;br&gt;
&lt;/span&gt; @i&lt;span style="color: gray"&gt;,&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; )&lt;br&gt;
&lt;/span&gt; 
&lt;p&gt;
&lt;span style="color: gray"&gt; 
&lt;/p&gt;
&lt;span style="color: blue"&gt; INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; Customers &lt;span style="color: blue"&gt;VALUES&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; (&lt;br&gt;
&lt;/span&gt; @i&lt;span style="color: gray"&gt;,&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;),&lt;br&gt;
&lt;/span&gt;&lt;span style="color: red"&gt; 'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: gray"&gt; )&lt;br&gt;
&lt;/span&gt;&gt; 
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: gray"&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;SET&lt;/span&gt; @i &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1&lt;br&gt;
&lt;span style="color: blue"&gt;END&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;When you now dump out the root index page of the non-unique clustered
index, you get the following result: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueNonUniqueClusteredIndexes_C59B/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueNonUniqueClusteredIndexes_C59B/image_thumb_1.png" width="476" height="220"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see, SQL Server returns here an additional column named &lt;strong&gt;UNIQUIFIER
(key)&lt;/strong&gt;. This column is used by SQL Server to make a non-unique clustered key
unique. Behind the scenes it is a 4 byte long integer value starting at 0. E.g. when
you have 2 customers with the ID 1380 the first record gets the uniquifier value 0
and the second one gets the uniquifier value of 1. But SQL Server only stores the
uniquifier in the navigation structure of an index (all levels above the leaf level),
when the uniquifier is not equal to 0. SQL Server only includes uniquifier values
of 0 in the navigation structure of a non-unique clustered index, which means that
the navigation structure will never store the uniquifier physically. The only place
where the uniquifier is stored in a non-unique clustered index is on the data pages,
where the actual data records are stored. The following figure shows a data page dump
of our clustered index, where you can also see the stored uniquifier. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueNonUniqueClusteredIndexes_C59B/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueNonUniqueClusteredIndexes_C59B/image_thumb_2.png" width="355" height="270"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So the only difference between a unique and non-unique clustered index is on the data
pages, because when using a non-unique clustered index, SQL Server will use the 4
byte long uniquifier to make them unique, which is a small storage overhead that you
have to keep in mind, when working with non-unique clustered indexes. You can download
the T-SQL script for this posting &lt;a href="http://www.csharp.at/downloads/SQL/ClusteredIndexStructure.zip"&gt;here&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
In the next posting we will work out the differences between unique/non-unique non-clustered
indexes defined on unique clustered indexes. Stay tuned :-) 
&lt;/p&gt;
&lt;p&gt;
-Klaus
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=98d6366f-9e37-4413-8435-793129ac87cb" /&gt;</content>
  </entry>
  <entry>
    <title>Unique and non-unique SQL Server indexes on a heap table</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,1deed441-b5bd-4adc-bd6f-1674e797cc42.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,1deed441-b5bd-4adc-bd6f-1674e797cc42.aspx</id>
    <published>2010-08-18T18:04:49.3220000+02:00</published>
    <updated>2010-09-04T10:58:30.1525572+02:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="SQLServer" label="SQLServer" scheme="http://www.csharp.at/blog/CategoryView,category,SQLServer.aspx" />
    <category term="SQLServerPedia" label="SQLServerPedia" scheme="http://www.csharp.at/blog/CategoryView,category,SQLServerPedia.aspx" />
    <content type="html">&lt;p&gt;
In the upcoming weblog postings I want to work out the differences between unique
and non-unique indexes in SQL Server. I assume that you already know the concepts
about clustered- and non clustered indexes and how they are used in SQL Server. 
&lt;/p&gt;
&lt;p&gt;
In the past I've done a lot of trainings and consulting regarding SQL Server performance
tuning and it seems that some people doesn't know the differences and implications
between unique and non-unique indexes. And as you will see in the upcoming postings
there are really big differences how SQL Server stores those two variants that impact
the size and the efficiency of your indexes. 
&lt;/p&gt;
&lt;p&gt;
Let's start today with unique and non unique non clustered indexes on a table without
a clustered index, a so-called &lt;strong&gt;heap table&lt;/strong&gt; in SQL Server. The following
listing shows how to create our test table and populate it with 80.000 records. Each
record needs 400 bytes, therefore SQL Server can put 20 records on each data page.
This means that our heap table contains 4.000 data pages and 1 IAM page. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a table
with 393 length + 7 bytes overhead = 400 bytes 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Therefore
20 records can be stored on one page (8.096 / 400) = 20,24 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; CustomersHeap 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerID &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerName &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; CustomerAddress &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;100&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; Comments &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;189&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Insert 80.000
records 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DECLARE&lt;/span&gt; @i &lt;span style="color: blue"&gt;INT&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 1 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;WHILE &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: gray"&gt;&lt;=&lt;/span&gt; 80000&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;BEGIN 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; CustomersHeap &lt;span style="color: blue"&gt;VALUES 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; @i&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerName'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'CustomerAddress'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'Comments'&lt;/span&gt; &lt;span style="color: gray"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@i &lt;span style="color: blue"&gt;AS&lt;/span&gt; &lt;span style="color: blue"&gt;CHAR&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: blue"&gt;SET&lt;/span&gt; @i &lt;span style="color: gray"&gt;+=&lt;/span&gt; 1 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;END 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Retrieve physical
information about the heap table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;SELECT&lt;/span&gt; &lt;span style="color: gray"&gt;*&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; &lt;span style="color: green"&gt;sys&lt;/span&gt;&lt;span style="color: gray"&gt;.&lt;/span&gt;&lt;span style="color: green"&gt;dm_db_index_physical_stats 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: fuchsia"&gt;DB_ID&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'NonClusteredIndexStructureHeap'&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: fuchsia"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'CustomersHeap'&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'DETAILED' 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
After the creation of the heap table and the data loading, you can now define a unique
and non-unique non-clustered index on the column &lt;strong&gt;CustomerID&lt;/strong&gt; of our
heap table. We will define both indexes on the same column so that we can analyze
the differences between unique- and non-unique non-clustered indexes. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a unique
non clustered index 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;UNIQUE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; IDX_UniqueNCI_CustomerID 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;ON&lt;/span&gt; CustomersHeap&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerID&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a non-unique
non clustered index 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX&lt;/span&gt; IDX_NonUniqueNCI_CustomerID 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;ON&lt;/span&gt; CustomersHeap&lt;span style="color: gray"&gt;(&lt;/span&gt;CustomerID&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
If you want to define a unique non-clustered index on a column that doesn't contain
unique data, you will get back an error message from SQL Server. Important to know
is that SQL Server creates a non-unique non-clustered index if you don't specify the &lt;strong&gt;UNIQUE&lt;/strong&gt; property
when creating a non-clustered index. So by default you will always get a non-unique
non-clustered index! 
&lt;/p&gt;
&lt;p&gt;
After the creation of both indexes you can analyze their size, their index depth,
their size etc. with the DMV &lt;strong&gt;sys.dm_db_index_physical_stats&lt;/strong&gt;. You
can to pass in as the 3rd parameter the index-id. The IDs of all non-clustered indexes
starts at 2, therefore the first non-clustered index gets the ID 2 and the second
one the ID 3. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Retrieve physical
information about the unique non-clustered index 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;SELECT&lt;/span&gt; &lt;span style="color: gray"&gt;*&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; &lt;span style="color: green"&gt;sys&lt;/span&gt;&lt;span style="color: gray"&gt;.&lt;/span&gt;&lt;span style="color: green"&gt;dm_db_index_physical_stats 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: fuchsia"&gt;DB_ID&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'NonClusteredIndexStructureHeap'&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: fuchsia"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'CustomersHeap'&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 2&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'DETAILED' 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Retrieve physical
information about the non-unique non-clustered index 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;SELECT&lt;/span&gt; &lt;span style="color: gray"&gt;*&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; &lt;span style="color: green"&gt;sys&lt;/span&gt;&lt;span style="color: gray"&gt;.&lt;/span&gt;&lt;span style="color: green"&gt;dm_db_index_physical_stats 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: fuchsia"&gt;DB_ID&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'NonClusteredIndexStructureHeap'&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: fuchsia"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'CustomersHeap'&lt;/span&gt;&lt;span style="color: gray"&gt;), 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; 3&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: gray"&gt;NULL, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; &lt;span style="color: red"&gt;'DETAILED' 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
As you can see from both outputs, the index root page of the unique non-clustered
index is occupied of around 24%, where the index root page of the non-unique non-clustered
index is occupied of around 39%, so there must be a difference in the storage format
of unique/non-unique non-clustered indexes on a heap table! In the next step we create
a simple helper table that stores the output of the &lt;strong&gt;DBCC IND&lt;/strong&gt; command.
The structure of this helper table is directly taken from the excellent book &lt;strong&gt;SQL
Server 2008 Internals&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Create a helper
table 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; sp_table_pages 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;( 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;PageFID &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;PagePID &lt;span style="color: blue"&gt;INT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; IAMFID &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; IAMPID &lt;span style="color: blue"&gt;INT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; ObjectID &lt;span style="color: blue"&gt;INT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; IndexID &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; PartitionNumber &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; PartitionID &lt;span style="color: blue"&gt;BIGINT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; iam_chain_type &lt;span style="color: blue"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;30&lt;span style="color: gray"&gt;),&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; PageType &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; IndexLevel &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; NextPageFID &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; NextPagePID &lt;span style="color: blue"&gt;INT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; PrevPageFID &lt;span style="color: blue"&gt;TINYINT&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt; PrevPagePID &lt;span style="color: blue"&gt;INT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt; PRIMARY
KEY &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;PageFID&lt;span style="color: gray"&gt;,&lt;/span&gt; PagePID&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: gray; font-size: 9pt"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
After the creation of this helper table we can dump out all pages that are belonging
to our non-clustered indexes to this helper table with the following two calls to
DBCC INC in combination with the &lt;strong&gt;INSERT INTO&lt;/strong&gt; statement: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Write everything
in a table for further analysis 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; sp_table_pages 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;EXEC&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'DBCC
IND(NonClusteredIndexStructureHeap, CustomersHeap, 2)'&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; color: green; font-size: 9pt"&gt;-- Write everything
in a table for further analysis 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; sp_table_pages 
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;EXEC&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'DBCC
IND(NonClusteredIndexStructureHeap, CustomersHeap, 3)'&lt;/span&gt;&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
Now we can start analyzing our non-clustered indexes by using the undocumented &lt;strong&gt;DBCC
PAGE&lt;/strong&gt; command. You can find more information about this great command on Paul
Randal's &lt;a href="http://sqlskills.com/BLOGS/PAUL/category/DBCC.aspx"&gt;weblog&lt;/a&gt;.
To get some information back from &lt;strong&gt;DBCC PAGE&lt;/strong&gt; you have to enable the
flag 3604 of DBCC: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; TRACEON&lt;span style="color: gray"&gt;(&lt;/span&gt;3604&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Let's dump out the index root page of our unique non-clustered index by the following
command: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;NonClusteredIndexStructureHeap&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 4192&lt;span style="color: gray"&gt;,&lt;/span&gt; 3&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
This will result in the following result in SQL Server Management Studio: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_thumb.png" width="450" height="268"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see from this screenshot SQL Server stores the child page of the B-tree
where the minimum key of the non-clustered index is located. The child page 4161 contains
for example the record with the minimum key of 540 up to the maximum key of 1078.
When you dump out the index root page with the dump option 1 you get the byte by byte
representation of all index records on the index root page: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;NonClusteredIndexStructureHeap&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 4192&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
SQL Server needs here 11 bytes for storing an index row. These 11 bytes are storing
the following information: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
1 byte: Status Bits 
&lt;li&gt;
4 bytes: Customer ID, like 540 
&lt;li&gt;
4 bytes: child PageID, like 4161 
&lt;li&gt;
2 bytes: FileID, like 1 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
As you can see it's up to the length of the non-clustered key how long an index row
is. This also means that SQL Server is able to store more index rows on an index page
if you choose a smaller non-clustered key. If you choose for example a &lt;strong&gt;CHAR(100)&lt;/strong&gt; as
a non-clustered index key, then SQL Server needs more index pages for your non-clustered
index, which is not so efficient as using a smaller index key. The T-SQL script enclosed
to this posting shows you how you can decode those bytes from the hexadecimal representation. 
&lt;/p&gt;
&lt;p&gt;
Finally you can dump out the child page 4161, which is located on the leaf-level of
the non-clustered index. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;NonClusteredIndexStructureHeap&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 4161&lt;span style="color: gray"&gt;,&lt;/span&gt; 3&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_thumb_1.png" width="448" height="252"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
As you can see from the figure, SQL Server stores for each index key on which data
page and on which slot the corresponding record is located. Because we have not defined
a clustered index on our table, SQL Server uses here the RID (Row Identifier) to point
to the correct record on the data page. Index pages on the leaf-level on a heap table
are different from leaf-level index pages defined on a clustered table (a table that
contains a clustered index).When you dump out the leaf-level index page of the non-clustered
index you can see that SQL Server needs 13 bytes per index row: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
1 byte: Status Bits 
&lt;li&gt;
4 bytes: CustomerID, like 540 
&lt;li&gt;
4 bytes: PageID, like 178, 
&lt;li&gt;
2 bytes: FileID, like 1 
&lt;li&gt;
2 bytes: Slot number, like 19 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Finally with this information in your hand, it is very easy to locate the correct
record on the data page, because you know the PageID, FileID, and also the slot number
where the record on the data page is located. Easy, isn't it? 
&lt;/p&gt;
&lt;p&gt;
Let's move on now to non-unique non-clustered indexes. Earlier we have already created
such an index, which gets the index-id of 3 from SQL Server, because it's the second
non-clustered index we have defined. In my case the index root page of the non-unique
non-clustered index is located on page 4264, therefore I dump it out with the following
command: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;DBCC&lt;/span&gt; PAGE&lt;span style="color: gray"&gt;(&lt;/span&gt;NonClusteredIndexStructureHeap&lt;span style="color: gray"&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;,&lt;/span&gt; 4264&lt;span style="color: gray"&gt;,&lt;/span&gt; 3&lt;span style="color: gray"&gt;) 
&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new; color: blue; font-size: 9pt"&gt;GO&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_thumb_2.png" width="544" height="279"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
But wait! Now the result from &lt;strong&gt;DBCC PAGE&lt;/strong&gt; on the root index page on
a non-unique non-clustered index is different! As you can see SQL Server returns here
an additional column named "&lt;strong&gt;HEAP RID (key)&lt;/strong&gt;". The value in this column
is used to make your non-unique non-clustered index unique. The &lt;strong&gt;HEAP RID&lt;/strong&gt; column
uses 8 additional bytes in your index row, which encodes the following information
that are granted to be unique on a heap table:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
4 bytes: PageID, like 178 
&lt;li&gt;
2 bytes: FileID, like 1 
&lt;li&gt;
2 bytes: Slot number, like 19 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The overead of a non-unique non-clustered index on a heap table costs you 8 additional
bytes per index row - on all index levels, expect the leaf-level, because SQL Server
stores here always the HEAP RID as you have seen previously! So please keep this 8
bytes of additional index record overhead in mind, when you create non-clustered indexed
that are NOT unique! And as I have said earlier, they are NOT unique by default!!! 
&lt;/p&gt;
&lt;p&gt;
In this example your non-unique non-clustered index is about 2 times bigger than the
unique non-clustered index, because the unique index needs 11 bytes and the non-unique
index needs 19 bytes (overhead of 8 bytes). When you look back to the output of the
DMV &lt;strong&gt;sys.dm_db_index_physical_stats&lt;/strong&gt; you can see that the index root
page of the unique non-clustered index has a page space usage of around 24% where
the index root page of the non-unique non-clustered index has a page space usage of
around 39%. This will make a big difference on large non-clustered indexes! 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/UniqueandnonuniqueSQLServerindexesonahea_FFFC/image_thumb_3.png" width="294" height="138"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So if you are just defining non-clustered indexes with 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-family: courier new; font-size: 9pt"&gt;&lt;span style="color: blue"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: blue"&gt;INDEX
...&lt;/span&gt;&lt;/span&gt; 
&lt;/p&gt;
&lt;p&gt;
without thinking about the uniqueness of your data, you are wasting a lot of storage
in your non-clustered indexes which also impacts the performance of your non-clustered
indexes and their ongoing maintenance. 
&lt;br&gt;
You can download the T-SQL script for this posting &lt;a href="http://www.csharp.at/Downloads/SQL/NonClusteredIndexStructure_Heap.txt" target="_blank"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
In the next installment of this series we will have a look into the differences of
unique clustered indexes and unique/non unique non-clustered indexes. Stay tuned :-) 
&lt;/p&gt;
&lt;p&gt;
-Klaus
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=1deed441-b5bd-4adc-bd6f-1674e797cc42" /&gt;</content>
  </entry>
  <entry>
    <title>Slides &amp;amp; Samples from my Solid Quality Summit sessions &amp;amp; workshop</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,56f4f922-9a2b-4c42-89b5-1ab5e5479298.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,56f4f922-9a2b-4c42-89b5-1ab5e5479298.aspx</id>
    <published>2010-06-26T10:45:16.7020000+02:00</published>
    <updated>2010-06-29T14:08:05.3796889+02:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.csharp.at/blog/CategoryView,category,Conferences.aspx" />
    <category term="SQL Server" label="SQL Server" scheme="http://www.csharp.at/blog/CategoryView,category,SQL%2BServer.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
As announced in my sessions and my workshop at the Solid Quality Summit in Vienna,
you can download the materials from here:
</p>
        <ul>
          <li>
            <a href="http://www.csharp.at/Downloads/FILESTREAM.zip">FILESTREAM Storage Attribute</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/StreamInsight.zip">SQL Server 2008 R2 StreamInsight</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/SQL2008DatabaseInternals.zip">SQL Server 2008
Database Internals</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/ExecutionPlans.zip">Understanding SQL Server
Execution Plans</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/IndexTuning.zip">SQL Server 2008 Index- and
Performance Tuning</a>
          </li>
        </ul>
        <p>
Thanks for attending my sessions and have fun :-)
</p>
        <p>
-Klaus
</p>
        <img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=56f4f922-9a2b-4c42-89b5-1ab5e5479298" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Slides &amp;amp; Samples for my Developer Camp Workshop</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,1e52a7ad-03c1-4ea2-af61-b5028e2f70f4.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,1e52a7ad-03c1-4ea2-af61-b5028e2f70f4.aspx</id>
    <published>2010-04-26T10:55:38.3950000+02:00</published>
    <updated>2010-04-26T10:56:21.8785439+02:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.csharp.at/blog/CategoryView,category,.NET.aspx" />
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.csharp.at/blog/CategoryView,category,Conferences.aspx" />
    <category term="SQL Server" label="SQL Server" scheme="http://www.csharp.at/blog/CategoryView,category,SQL%2BServer.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
As announced in my Developer Camp workshop in Berlin you can download my workshop
material from here:
</p>
        <ul>
          <li>
            <a href="http://www.csharp.at/Downloads/DeveloperCamp.zip">SQLCLR/Service Broker</a>
          </li>
        </ul>
        <p>
Thanks for attending my workshop and have fun :-)
</p>
        <p>
-Klaus
</p>
        <img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=1e52a7ad-03c1-4ea2-af61-b5028e2f70f4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Slides &amp;amp; Samples for my European PASS session</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,a0d408eb-bf71-4dec-90f0-311cdd7c23f3.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,a0d408eb-bf71-4dec-90f0-311cdd7c23f3.aspx</id>
    <published>2010-04-26T10:51:41.8340000+02:00</published>
    <updated>2010-04-26T10:56:31.0658675+02:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.csharp.at/blog/CategoryView,category,.NET.aspx" />
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.csharp.at/blog/CategoryView,category,Conferences.aspx" />
    <category term="SQL Server" label="SQL Server" scheme="http://www.csharp.at/blog/CategoryView,category,SQL%2BServer.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
As announced in my European PASS session you can download my session material from
here:
</p>
        <ul>
          <li>
            <a href="http://www.csharp.at/Downloads/filestream.zip">FILESTREAM Storage Attribute</a>
          </li>
        </ul>
        <p>
Thanks for attending my session and have fun :-)
</p>
        <p>
-Klaus
</p>
        <img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=a0d408eb-bf71-4dec-90f0-311cdd7c23f3" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Slides &amp;amp; Samples for my VSOne sessions</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,2a5a2612-3e1d-4617-9c7e-0f700697e662.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,2a5a2612-3e1d-4617-9c7e-0f700697e662.aspx</id>
    <published>2010-02-27T18:24:49.5360000+01:00</published>
    <updated>2010-02-27T18:27:57.7825495+01:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.csharp.at/blog/CategoryView,category,.NET.aspx" />
    <category term="Conferences" label="Conferences" scheme="http://www.csharp.at/blog/CategoryView,category,Conferences.aspx" />
    <category term="SQL Server" label="SQL Server" scheme="http://www.csharp.at/blog/CategoryView,category,SQL%2BServer.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
As announced in my VSOne sessions and in my workshop you can download my session material
from here:
</p>
        <ul>
          <li>
            <a href="http://www.csharp.at/Downloads/FileStream.zip">FILESTREAM Storage Attribute</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/StreamInsight.zip">StreamInsight</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/DWH.zip">Effektive SSIS ETL Prozesse</a>
          </li>
          <li>
            <a href="http://www.csharp.at/Downloads/DWH.zip">Data Warehouse/Busines Intelligence
Workshop</a>
          </li>
        </ul>
        <p>
Thanks for attending my sessions and have fun :-)
</p>
        <p>
-Klaus
</p>
        <img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=2a5a2612-3e1d-4617-9c7e-0f700697e662" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Philip Aschenbrenner</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,6ff4df09-c10d-42f0-b06a-fd8b36c8e6c6.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,6ff4df09-c10d-42f0-b06a-fd8b36c8e6c6.aspx</id>
    <published>2010-02-06T10:54:58.0150000+01:00</published>
    <updated>2010-02-06T10:55:42.4201635+01:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="Personal" label="Personal" scheme="http://www.csharp.at/blog/CategoryView,category,Personal.aspx" />
    <content type="html">&lt;ul&gt;
&lt;li&gt;
Born on February 4, 2010 – 09:08 
&lt;li&gt;
3210 gr 
&lt;li&gt;
51 cm 
&lt;li&gt;
All systems are up &amp; running :-)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/PhilipAschenbrenner_9975/IMGA0006.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IMGA0006" border="0" alt="IMGA0006" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/PhilipAschenbrenner_9975/IMGA0006_thumb.jpg" width="644" height="431"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/PhilipAschenbrenner_9975/IMGA0015.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IMGA0015" border="0" alt="IMGA0015" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/PhilipAschenbrenner_9975/IMGA0015_thumb.jpg" width="644" height="431"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
-Philip, Karin &amp; Klaus
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=6ff4df09-c10d-42f0-b06a-fd8b36c8e6c6" /&gt;</content>
  </entry>
  <entry>
    <title>Flightdeck Breitenlee &amp;ndash; a Boeing 737-800 Flight Simulator</title>
    <link rel="alternate" type="text/html" href="http://www.csharp.at/blog/PermaLink,guid,1909abef-de02-436b-a81e-b6b6e67f419b.aspx" />
    <id>http://www.csharp.at/blog/PermaLink,guid,1909abef-de02-436b-a81e-b6b6e67f419b.aspx</id>
    <published>2010-01-13T10:08:13.5310000+01:00</published>
    <updated>2010-01-13T10:10:00.7165182+01:00</updated>
    <category term=".NET German" label=".NET German" scheme="http://www.csharp.at/blog/CategoryView,category,.NET%2BGerman.aspx" />
    <category term="FlightSimulation" label="FlightSimulation" scheme="http://www.csharp.at/blog/CategoryView,category,FlightSimulation.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
It’s 4:30pm on a nice autumn day, the sun stands deep in the west of Vienna, and during
it’s decent the horizon’s color slowly changes to red. In the next minutes we will
get a wonderful sunset here in Vienna. Unfortunately my copilot and I have no time
to relax and join the sunset, because we are currently sitting in a Boeing 737-800
and our lineup at the runway 29 in Vienna Schwechat was a few minutes ago. A few seconds
ago, Schwechat tower has given us the clearance for takeoff with the following impressive
words: “<i>OE-AKS, cleared for takeoff on runway 29”.</i></p>
        <p>
We have successfully completed our prestart checklists, my left hand holds the yoke
of the Boeing 737-800, and my right hand is on the throttle lever, which I move very
carefully forward. After both engines have established, I release the parking brake,
and activate the auto-throttle, which takes the control and management of both engines.
A few seconds after our acceleration, my copilot calls out “<i>80 knots</i>” to inform
me that both speed indicators are showing the same speed. A few seconds after, my
cocpilot calls-out “<i>V1</i>” and I take my right hand away from the throttle lever
– now there is no return for us – we have to start whatever event occurs! 
</p>
        <p>
After a few seconds, my copilot calls-out “<i>VR</i>” and I rotate the nose of the
Boeing for around 3° per seconds after we have reached an angle of climb of around
15°. After our climb angle is positive, my copilot retracts the landing gear, and
I activate the auto-pilot, which flies us with the SID “<i>SITNI 4C</i>”, which we
have programmed earlier on the FMC, through the west out of the airport Vienna. But
then, a few seconds before we reach our next waypoint, the unavoidable occurs, for
which we had danger till the takeoff in Vienna: the cockpit door opens, and someone
says to us: “<i>Honey, dinner is ready, will you now come!?</i>” 
</p>
        <p>
You have though that this story occurred in a real Boeing 737-800? You are completely
wrong – welcome to <b>Flightdeck Breitenlee</b>, a Boeing 737-800 flight simulator
in Vienna! The Flightdeck Breitenlee is a home-build Boeing 737-800 flight simulator,
planned, builded and programmed by Klaus Aschenbrenner, which is now rented for your
flight experiences. Currently the Flightdeck Breitenlee is driven by 5 high-end computers,
and in the final step the flight simulator will have around 9 – 10 computers working
in a network! 
</p>
        <p>
Who hasn’t dreamed as a child, to fly a big airliner such as a Boeing or an Airbus
around the world? But unfortunately this child dream doesn’t come alive for some of
us. On the other hand, till 9/11 you had the chance to walk into the cockpit during
a flight and join the crew on the so-called “Jump seat” and watch their work in the
air. But after 9/11 there is now no chance to get into the cockpit anymore… The only
left option is to visit a flight simulator, like the A320 flight simulator at the
Vienna Aviation Campus hosted by Lufthansa Flight Training. But a whole flight hour
costs here around € 800 – of course without any flight instructor! So it’s not a real
alternative… 
</p>
        <p>
The Flightdeck Breitenlee provides you for a fair price an almost high realistic simulated
Boeing 737-800 flight simulator, based on the Microsoft Flight Simulator FSX. The
whole building time of the flight simulator took around 2 years, where the planning
and the research already started in the beginnings of the year 2006. Currently the
Flightdeck Breitenlee offers you the following systems for your VFR/IFR flights: 
</p>
        <ul>
          <li>
The FMC (Flight Management Computer) simulates the whole pages of a Smiths CDU and
enables you a complete flight planning with the creation of the necessary flight routes. 
</li>
          <li>
The MCP (Mode Control Panel) includes the auto-pilot and simulates the following modes: 
<ul><li>
LNAV (in combination with the FMC)^ 
</li><li>
VNAV (in combination with the FMC) 
</li><li>
HDG SEL 
</li><li>
LVL CHG 
</li><li>
VOR LOC 
</li><li>
APP 
</li><li>
ALT HOLD 
</li><li>
V/S 
</li><li>
SPEED 
</li><li>
N1</li></ul></li>
          <li>
Through the EFIS you can control the ND display. The following modes are supported: 
<ul><li>
APP 
</li><li>
VOR 
</li><li>
MAP 
</li><li>
PLAN</li></ul></li>
          <li>
The motorized (yes, the throttle levers are moving during auto-throttle mode!) throttle
quadrant includes: 
<ul><li>
2 motorized throttle levers 
</li><li>
Parking brake 
</li><li>
Speed-Brake 
</li><li>
Flaps-Lever</li></ul></li>
          <li>
The MIP (Main Instrument Panel) includes: 
<ul><li>
3 LCD monitors, which represents the whole glass-cockpit of the Boeing 737-800 
</li><li>
All annunicators are fully simulated 
</li><li>
Gear-Lever 
</li><li>
Flaps-Gauge 
</li><li>
Realistic Auto-Break System (RTO, 1, 2, 3, MAX)</li></ul></li>
          <li>
The center pedestal includes 
<ul><li>
2x NAV Panel 
</li><li>
2x COM Panel 
</li><li>
2x ADF Panel 
</li><li>
2x Mic Selectors 
</li><li>
Weather radar 
</li><li>
TCAS Transponder 
</li><li>
1x SELCAL 
</li><li>
Cargo Fire Panel</li></ul></li>
          <li>
The Instructor Station concluces the Flightdeck Breitenlee, with which all possible
failures and errors can be introduced into the ongoing flight. You can also control
the behavior of the weather within a few seconds. Do you wanted to do a CAT III landing
in Vienna with fog and heavy crosswind on Runway 11? For the simulator it’s not a
problem – and for you?</li>
        </ul>
        <p>
For further information about the Flightdeck Breitenlee you can directly contact Klaus
Aschenbrenner, where you can also arrange the boarding for your first Boeing 737-800
flight on the pilot’s seat! 
</p>
        <p>
Klaus Aschenbrenner<br />
Pichlgasse 16/6<br />
A-1220 Wien<br />
http:<a href="http://flightdeck.csharp.at">//flightdeck.csharp.at<br /><a href="mailto:Klaus.Aschenbrenner@csharp.at">Klaus.Aschenbrenner@csharp.at</a><br /></a>+43 676 833 04 341
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00784_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00784_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
The center pedestal
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00788_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00788_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
The center pedestal
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00789_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00789_thumb.jpg" width="695" height="926" />
          </a>
        </p>
        <p>
The throttle quadrant
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00793_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00793_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
The EICAS
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00794_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00794_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
The PFD and ND
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00797_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00797_thumb.jpg" width="695" height="926" />
          </a>
        </p>
        <p>
COM-, NAV- and ADF panels
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00804_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00804_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
The keypad of the CDU
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00805_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00805_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
Auto Break and Flaps Panel
</p>
        <p>
          <a href="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00809_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://www.csharp.at/blog/content/binary/WindowsLiveWriter/FlightdeckBreitenleeaBoeing737800FlightS_8E81/DSC00809_thumb.jpg" width="926" height="695" />
          </a>
        </p>
        <p>
The MCP
</p>
        <img width="0" height="0" src="http://www.csharp.at/blog/aggbug.ashx?id=1909abef-de02-436b-a81e-b6b6e67f419b" />
      </div>
    </content>
  </entry>
</feed>