Thursday, December 20, 2012

sys.dm_db_stats_properties() - Initial Results on SQL 2008 R2 SP2

My first sys.dm_db_stats_properties() post showed results for SQL Server 2012 SP1. Here, I will show how the results for filtered indexes on 2008 R2 SP2 are different.

The test script is exactly the same as before, just running on a different version.

MSDN Docs

The 2008 R2 version of the docs is here. Because the results were different, I pulled the text for both the 2012 document and the 2008 R2 document and compared them. There are no substantive differences.

Here are the only differences:
2008 R2 SP2"Requires that the user owns the table or the user is a member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database role."
2012 SP1 adds the highlighted section"Requires that the user has select permissions on statistics columns or the user owns the table or the user is a member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database role."

Results

Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64) 
   Jun 28 2012 08:36:30 
   Copyright (c) Microsoft Corporation
   Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

Beginning execution loop
Batch execution completed 10000 times.
name              filter_definition last_updated        rows  rows_sampled steps unfiltered_rows modification_counter
----------------- ----------------- ------------------- ----- ------------ ----- --------------- --------------------

name              filter_definition last_updated        rows  rows_sampled steps unfiltered_rows modification_counter
----------------- ----------------- ------------------- ----- ------------ ----- --------------- --------------------
AK_Test1_ColGuid  NULL              2012-12-20 09:10:09 10000 10000        132   10000           0
IX_Test1_Deleted  NULL              2012-12-20 09:10:09 10000 10000        1     10000           0
IX_Test1_StatusId NULL              2012-12-20 09:10:09 10000 10000        1     10000           0
PK_Test1_ColId    NULL              2012-12-20 09:10:09 10000 10000        3     10000           0

Update Count: 5000
name              filter_definition last_updated        rows  rows_sampled steps unfiltered_rows modification_counter
----------------- ----------------- ------------------- ----- ------------ ----- --------------- --------------------
AK_Test1_ColGuid  NULL              2012-12-20 09:10:09 10000 10000        132   10000           0
IX_Test1_Deleted  NULL              2012-12-20 09:10:09 10000 10000        1     10000           5000
IX_Test1_StatusId NULL              2012-12-20 09:10:09 10000 10000        1     10000           5000
PK_Test1_ColId    NULL              2012-12-20 09:10:09 10000 10000        3     10000           0

Observations

Filtered Index Results
Filtered indexes are excluded from these results where they return NULLs in 2012.

The difference appears to be in the fact that the function returns a row in 2012 for a filtered index and does not return a row in 2008 R2 for a filtered index.


No comments:

Post a Comment