Table of Contents

Class ObjectSchema.Stat

Namespace
LinqToDB.Tools.DataProvider.SqlServer.Schemas
Assembly
linq2db.Tools.dll

sys.stats (Transact-SQL)

Applies to:SQL ServerAzure SQL DatabaseAzure SQL Managed InstanceAzure Synapse AnalyticsAnalytics Platform System (PDW)SQL analytics endpoint in Microsoft FabricWarehouse in Microsoft Fabric

Contains a row for each statistics object that exists for the tables, indexes, and indexed views in the database in SQL Server. Every index will have a corresponding statistics row with the same name and ID (index_id = stats_id), but not every statistics row has a corresponding index.
The catalog view sys.stats_columns provides statistics information for each column in the database.
For more information about statistics, see Statistics.
::: moniker range='=fabric'

note


For more information on statistics in Microsoft Fabric, see [Statistics in Microsoft Fabric](/fabric/data-warehouse/statistics).



::: moniker-end

See sys.stats.

[Table(Schema = "sys", Name = "stats", IsView = true)]
public class ObjectSchema.Stat
Inheritance
ObjectSchema.Stat
Inherited Members
Extension Methods

Properties

AutoCreated

auto_created NULL bit

Indicates whether the statistics were automatically created by SQL Server.

0 = Statistics were not automatically created by SQL Server.

1 = Statistics were automatically created by SQL Server.
[Column("auto_created")]
[Nullable]
public bool? AutoCreated { get; set; }

Property Value

bool?

AutoDrop

auto_drop NULL bit

Indicates whether or not the auto drop feature is enabled for this statistics object. The AUTO_DROP property allows the creation of statistics objects in a mode such that a subsequent schema change will not be blocked by the statistic object, but instead the statistics will be dropped as necessary. In this way, manually created statistics with AUTO_DROP enabled behave like auto-created statistics. For more information, see AUTO_DROP option.

Applies to: Azure SQL Database, Azure SQL Managed Instance, and starting with SQL Server 2022 (16.x).
[Column("auto_drop")]
[Nullable]
public bool? AutoDrop { get; set; }

Property Value

bool?

FilterDefinition

filter_definition NULL nvarchar(max)

Expression for the subset of rows included in filtered statistics.

NULL = Non-filtered statistics.
[Column("filter_definition")]
[Nullable]
public string? FilterDefinition { get; set; }

Property Value

string

HasFilter

has_filter NULL bit

0 = Statistics do not have a filter and are computed on all rows.

1 = Statistics have a filter and are computed only on rows that satisfy the filter definition.
[Column("has_filter")]
[Nullable]
public bool? HasFilter { get; set; }

Property Value

bool?

HasPersistedSample

has_persisted_sample NULL bit

Indicates whether the statistics were created or updated with the PERSIST_SAMPLE_PERCENT option.

0 = Statistics are not persisting the sample percentage.

1 = Statistics were created or updated with the PERSIST_SAMPLE_PERCENT option.

Applies to: SQL Server (Starting with SQL Server 2019 (15.x))
[Column("has_persisted_sample")]
[Nullable]
public bool? HasPersistedSample { get; set; }

Property Value

bool?

IsIncremental

is_incremental NULL bit

Indicate whether the statistics are created as incremental statistics.

0 = The statistics are not incremental.

1 = The statistics are incremental.

Applies to: SQL Server (Starting with SQL Server 2014 (12.x))
[Column("is_incremental")]
[Nullable]
public bool? IsIncremental { get; set; }

Property Value

bool?

IsTemporary

is_temporary NULL bit

Indicates whether the statistics is temporary. Temporary statistics support Always On availability groups secondary databases that are enabled for read-only access.

0 = The statistics is not temporary.

1 = The statistics is temporary.

Applies to: SQL Server (Starting with SQL Server 2012 (11.x))
[Column("is_temporary")]
[Nullable]
public bool? IsTemporary { get; set; }

Property Value

bool?

Name

name NULL sysname

Name of the statistics. Is unique within the object.
[Column("name")]
[Nullable]
public string? Name { get; set; }

Property Value

string

NoRecompute

no_recompute NULL bit

Indicates whether the statistics were created with the NORECOMPUTE option.

0 = Statistics were not created with the NORECOMPUTE option.

1 = Statistics were created with the NORECOMPUTE option.
[Column("no_recompute")]
[Nullable]
public bool? NoRecompute { get; set; }

Property Value

bool?

Object

objects (sys.objects)

[Association(ThisKey = "ObjectID", OtherKey = "ObjectID", CanBeNull = false)]
public ObjectSchema.Object Object { get; set; }

Property Value

ObjectSchema.Object

ObjectID

object_id NOT NULL int

ID of the object to which these statistics belong.
[Column("object_id")]
[NotNull]
public int ObjectID { get; set; }

Property Value

int

StatsGenerationMethod

stats_generation_method NOT NULL int

Indicates the method by which statistics are created.

0 = Sort based statistics

1 = Internal use only

Applies to: SQL Server (Starting with SQL Server 2019 (15.x))
[Column("stats_generation_method")]
[NotNull]
public int StatsGenerationMethod { get; set; }

Property Value

int

StatsGenerationMethodDesc

stats_generation_method_desc NOT NULL varchar(255)

The text description of the method by which statistics are created.

Sort based statistics

Internal use only

Applies to: SQL Server (Starting with SQL Server 2019 (15.x))
[Column("stats_generation_method_desc")]
[NotNull]
public string StatsGenerationMethodDesc { get; set; }

Property Value

string

StatsID

stats_id NOT NULL int

ID of the statistics. Is unique within the object.

If statistics correspond to an index, the *stats_id* value is the same as the *index_id* value in the sys.indexes catalog view.
[Column("stats_id")]
[NotNull]
public int StatsID { get; set; }

Property Value

int

UserCreated

user_created NULL bit

Indicates whether the statistics were created by a user.

0 = Statistics were not created by a user.

1 = Statistics were created by a user.
[Column("user_created")]
[Nullable]
public bool? UserCreated { get; set; }

Property Value

bool?