{"id":353,"date":"2021-09-18T13:16:51","date_gmt":"2021-09-18T07:46:51","guid":{"rendered":"http:\/\/sumitjangid.com\/?p=353"},"modified":"2021-09-18T13:16:51","modified_gmt":"2021-09-18T07:46:51","slug":"heap","status":"publish","type":"post","link":"http:\/\/sumitjangid.com\/index.php\/2021\/09\/18\/heap\/","title":{"rendered":"Heap"},"content":{"rendered":"\n<h4>What is a SQL Server Heap?<\/h4>\n\n\n\n<p>Before we get into the different types of indexes that are available in SQL Server we should first describe the basic structure of a table.&nbsp; Tables with no clustered index defined (more on that later) are stored in a heap structure which essentially means that the data is stored as an unordered data set in each page.<\/p>\n\n\n\n<h4>SQL Server Heap Benefits and Usage<\/h4>\n\n\n\n<p>The main use case for implementing a heap structure is when you require fast INSERT performance on your table.&nbsp; Think of a log or audit table where new data is constantly being written.&nbsp; With a heap structure, there is no need for the database engine to figure out where to insert the new data.&nbsp; It simply adds data to the last page or if full, allocates a new page and writes the data in that page.<\/p>\n\n\n\n<h4>SQL Server Heap Disadvantages<\/h4>\n\n\n\n<p>Querying a heap table can be very slow.\u00a0 Especially if there aren&#8217;t any non-clustered indexes defined on the table.\u00a0 Without any indexes, every query that accesses the heap table must perform a full table scan and we all know how expensive that can be if the table is large.<\/p>\n\n\n\n<p>Create a table with no primary key or clustered index, and you have a heap table.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is a SQL Server Heap? Before we get into the different types of indexes that are available in SQL Server we should first describe the basic structure of a table.&nbsp; Tables with no clustered&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[],"_links":{"self":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/353"}],"collection":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":1,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":354,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions\/354"}],"wp:attachment":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}