{"id":1343,"date":"2014-03-17T09:00:00","date_gmt":"2014-03-17T16:00:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/dataplatforminsider\/2014\/03\/17\/the-new-and-improved-cardinality-estimator-in-sql-server-2014\/"},"modified":"2024-01-22T22:49:00","modified_gmt":"2024-01-23T06:49:00","slug":"the-new-and-improved-cardinality-estimator-in-sql-server-2014","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2014\/03\/17\/the-new-and-improved-cardinality-estimator-in-sql-server-2014\/","title":{"rendered":"The New and Improved Cardinality Estimator in SQL Server 2014"},"content":{"rendered":"

One area where a lot of development work went into SQL Server 2014 is the area of query optimization where a crucial component got re-written in order to improve query access and predictability.<\/p>\n

To get a better idea about the significance of the change and the way how one should deal with it, let\u2019s first check what the component of cardinality estimation is responsible for.\u00a0<\/p>\n

When a query is executed for the first time, it is getting \u2018compiled\u2019. In opposite to a compilation of executables where we talk about binary compilation, the compilation of a SQL Statement is limited to figuring out the most efficient access to the data requested. This means, for example, the query engine needs to decide which index to pick in order to have the most efficient access to the data rows or, in case of table joins, the order of the join and the join methods need to be decided. At the end of the compilation there is a descriptive query plan which will be cached. During the execution phase the query plan is read from cache and interpreted. Since compilation of a query plan represents significant resource consumption, one usually is keen to cache these query plans.<\/p>\n

At a very high level, the Query Optimizer uses the following input (in order) during the compilation phase:<\/p>\n