Columnstore Indexes – part 90 (“In-Memory Columnstore Improvements in Service Pack 1 of SQL Server 2016 “)

Continuation from the previous 89 parts, the whole series can be found at

This blog post is focusing on a very important improvement to the limitation of the In-Memory Columnstore Indexes that was existing in SQL Server 2016, but was solved in the Service Pack 1 – the possibility to add the Columnstore Indexes to the Memory-Optimised table as fast as the other indexes, be it Hash or Nonclustered BW-Tree index.

In Columnstore Indexes – part 81 (“Adding Columnstore Index to InMemory Tables”) I have shown that while adding a Nonclustered Index to Memory-Optimised table, it takes a very short amount of time compared to adding the Clustered Columnstore Index
and in Columnstore Indexes – part 89 (“Memory-Optimised Columnstore Limitations 2016”), I have shown the impact to the persistent storage after adding Columnstore Index, which is doubling the occupied space of the original table, while the Nonclustered Indexes (Hash or BW-Tree) would simply add a couple of MB most probably reflecting the meta-information overhead.

With an incredible Service Pack 1 Microsoft has triumphantly announced that all editions (Standard, Web, Express and even Local) will get the most advanced programming capabilities of Columnstore, In-Memory, Database Snapshot, Compression, Partition & many others, plus that there are some incredible features for the T-SQL (CREATE OR ALTER) and Execution Plan details (Actual Information on processed Rows, used Trace Flags, etc),
but at the same time there are some quite important improvement under the hood that will make you want to use Service Pack 1 for SQL Server 2016 immediately. One of this features is the fast addition of the Columnstore Index to the Memory-Optimised tables. Let take it to the test by restoring a copy of the ContosoRetailDW free database:

Do not forget to set the compatibility level to 130, otherwise you will be missing enough important features that require it. Now, let’s add a Memory-Optimised Filegroup to our database:

For the test, I will use an empty Memory-Optimised table where I shall load 2 million rows from the original FactOnlineSales table.

Checking on the file System directly one can see the checkpoint files added with around 450 MB of occupied space, which looks exactly like the results for the SQL Server 2016 RTM tests that I did previously:

Using the MOSL, let’s see the detailed information on the Checkpoint Files after the initial load of 2 million rows: here we can confirm that everything is still the same:


Now let’s test the addition of the Columnstore Index to our Memory-Optimised table:

You gotta put your cup of coffee down, before looking at the results: 218 ms of the CPU time and the total elapsed time was just 2064 ms ! The total elapsed time simply went down from over 7 seconds down to just 2 second! Regarding the used CPU time there is a huge difference with the original RTM CPU time being around 4.1 seconds vs 0.2 seconds in the Service Pack 1.
Incredible! That is one amazing addition in “just a Service Pack”!

What about the Checkpoint Files and their impact on the disk:

Here we can see the the total size of the reserved space went from 476 MB to 526 MB, meaning that we have increased 50 MB in total, but the used space was kept intact on 328 MB in comparison to the RTM version where the 672 MB of the space were used. The difference here is huge with 0 MB vs 340 MB, justifying the impact of the operation speed.

What about the changes for Nonclustered Hash Indexes? Are there any ?
Let’s test the addition of the Nonclustered Hash Index to a Memory-Optimised table, but notice that for doing a fair comparison, all previous scripts besides Columnstore index addition should be re-executed again.

total-time-spent-on-index-additionThe execution time was the same as for the RTM version of SQL Server 2016 – 2990 ms, while the CPU spent time was 3060 ms.
This means that adding a Columnstore Index runs faster than adding a Nonclustered Hash Index, because we have 2 seconds for the Columnstore Index addition while having 3 seconds for Nonclustered Hash Index addition!
That is quite a reversal of the fortune, when comparing to the RTM version!

cpu-time-spent-on-index-additionThe amount of CPU time spent on the addition of the indexes has suffered a very significant change as well – it takes just 0.2 seconds of the CPU time to add a Columnstore Index while it takes a good 3 seconds to add a Nonclustered Hash Index to a Memory-Optimised Table.

Additional note comes here on the addition of the Nonclustered BW-Tree Index, which spends 4.1 seconds on the total execution, while spending 3.2 of the CPU time – time making the worst time when compared with all other indexes.

From the Checkpoint File perspective we can observe a stable :

This time we have just received 16 MB of the reserved space and nothing from the point of view of the occupied space.
Another interesting area for the investigation is the addition of the 1957 rows while adding a Columnstore Index while nothing changes when adding a Hash Index. I will be writing on this matter in the near future.

Transaction Log

I have also done some transaction log measurements for the impact on the transaction log with the help of the following statement:

The impact on the transaction log when adding Columnstore Indexes continued to be quite significant, but in comparison of the SQL Server 2016 RTM version where it took 380 MB, in the Service Pack 1 the total impact on the transactional log went down to just 41 MB!
Comparing to the addition of the Nonclustered Hash Index still can’t be truly done, since it is just around 260 KB (yes, Kilobytes) that transaction log receives after this operation, we are talking about difference in around 160 times.

Final Thoughts

We can observe a truly great improvement with Columnstore Indexes in the Service Pack 1 and it is just another reason for upgrading to it, even if you are running SQL Server 2016 RTM.
The next natural step will be guaranteeing that addition of the all indexes to Memory-Optimised table takes place online, in order to keep the business running without any interruption.
Another aspect to keep on improving will be the transaction log – the improvements in Service Pack 1 are great but there is still enough room for the improvement.

to be continued with Columnstore Indexes – part 91 (“SQL Server 2016 Standard Edition Limitations”)

Leave a Reply

Your email address will not be published. Required fields are marked *