Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Heaps are just tables without a clustering key - without a key that enforces a certain physical order.</p> <p>I would not really recommend having heaps at any time - except maybe if you use a table temporarily to bulk-load an external file, and then distribute those rows to other tables.</p> <p>In every other case, I would strongly recommend using a clustering key. SQL Server will use the Primary Key as the clustering key by default - which is a good choice, in most cases. UNLESS you use a GUID (UNIQUEIDENTIFIER) as your primary key, in which case using that as your clustering key is a horrible idea.</p> <p>See Kimberly Tripp's excellent blog posts <a href="http://www.sqlskills.com/BLOGS/KIMBERLY/post/GUIDs-as-PRIMARY-KEYs-andor-the-clustering-key.aspx" rel="noreferrer">GUIDs as Primary and/or the clustering key</a> and <a href="http://www.sqlskills.com/BLOGS/KIMBERLY/post/The-Clustered-Index-Debate-Continues.aspx" rel="noreferrer">The Clustered Index Debate Continues</a> for excellent explanations why you should always have a clustering key, and why a GUID is a horrible clustering key.</p> <p>My recommendation would be:</p> <ul> <li>in 99% of all cases try to use a <code>INT IDENTITY</code> as your primary key and let SQL Server make that the clustering key as well</li> <li>exception #1: if you're bulk loading huge data amounts, you might be fine without a primary / clustering key for your temporary table</li> <li>exception #2: if you must use a GUID as your primary key, then set your clustering key to a different column - preferably a <code>INT IDENTITY</code> - and I would even create a separate INT column just for that purpose, if no other column can be used</li> </ul> <p>Marc</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload