Question

I have an instance which runs on SQL Server 2017 Developer Edition instance. I restored database ContosoRetailDW which had compatibility level 100. After restore operation, I run the following query:

CREATE CLUSTERED COLUMNSTORE INDEX CCI_FactOnlineSales ON dbo.FactOnlineSales

The columnstore index was successfully created.

My question is related to the compat level. As far as I know, the columnstore index concept itself was came out in SQL Server 2012. Moreover, the clustered columnstore index was released in SQL Server 2014. How come database with compat level 100 support clustered columnstore index? It seems that database still inherits features of the current instance.

Was it helpful?

Solution

Compat level is there to provide a higher degree of backwards compatibility. We can put this into a few categories:

Language elements that has been removed in a higher version of SQL server can still be available in that version of you run with a lower compat level. There aren't many of those nowadays.

Behavior changes can keep the old behavior with the lower compat level.

New language elements that in a higher version now are keywords/reserved words. I.e., if you have an object named this way ("identifier", formally), you will in this higher version have to [delimit] when you reference that identifier. In order to provide backwards compatibility, in a lower compat level, those new language elements won't be available. Note, however, that there are plenty of new language elements that do not introduce new keywords, and don't have to be blocked in the lower compat level.

Performance. Use a lower compat level, and you are likely to have the same execution plans as if you were running in that version. I.e., no performance surprises when you upgrade the engine version assuming that you keep the old db compat level. Ideally.

There is no need to block new features if allowing them don't introduce backwards compatibility issues. Your columnstore index is such an example.

As for exactly what each compat level do, this is well documented here: https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top