Table of Contents

Class ObjectSchema.Stat

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

sys.stats (Transact-SQL)

Applies to: √ SQL Server (all supported versions) √ Azure SQL Database √ Azure SQL Managed Instance √ Azure Synapse Analytics √ Analytics Platform System (PDW)

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.


See sys.stats.

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

Properties

AutoCreated

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?

FilterDefinition

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

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

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

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

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 of the statistics. Is unique within the object.

[Column("name")]
[Nullable]
public string? Name { get; set; }

Property Value

string

NoRecompute

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

ID of the object to which these statistics belong.

[Column("object_id")]
[NotNull]
public int ObjectID { get; set; }

Property Value

int

StatsGenerationMethod

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

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

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

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?