Statistics and Natively Compiled Procedures

SQL Server 2014, TSQL
Statistics are one of the single most important driving factors for the behavior of the query optimizer. The cardinality estimates stored within the statistics drive costing and costing drives the decision making of the optimizer. So, how does this work with the new SQL Server 2014 natively compiled procedures? Differently. In-memory tables do not maintain their statistics automatically. Further, you can't run DBCC SHOW_STATISTICS to get information about those statistics, so you can't tell if they're out of date or not or what the distribution of the data is within them. So, if I create some memory optimized tables, skip loading any data into them and then run this standard query: [crayon-5a6d1c2e8384a184249026/] The estimates in the execution plan for the query show some pretty wild values: That's an estimated number of rows…
Read More

Differences In Native Compiled Procedures Execution Plans

SQL Server 2014
All the wonderful functionality that in-memory tables and natively compiled procedures provide in SQL Server 2014 is pretty cool. But, changes to core of the engine results in changes in things that we may have developed a level of comfort with. In my post last week I pointed out that you can't see an actual execution plan for natively compiled procedures. There are more changes than just the type of execution plan available. There are also changes to the information available within the plans themselves. For example, I have a couple of stored procedures, one running in AdventureWorks2012 and one in an in-memory enabled database with a few copies of AdventureWorks tables: [crayon-5a6d1c2e8866f304020871/] The execution plans are obviously a little bit different, one going against in-memory tables and indexes and the other…
Read More