sp_modifystats

Allows the system administrator, or any user with permission to execute the procedure and update statistics on the target table, to modify the density values of columns in sysstatistics.

Syntax

sp_modifystats [database].[owner].table_name,
	{"column_group" | "all"},
	modify_density,
	{range | total},
	{absolute | factor},
	"value"
    modify_default_selectivity,     
    {inequality | inbetween},     
    {absolute | factor}, 
    "value"
    modify_unique     
    {range | total },     
    {absolute | factor},
    "value"

Or:

sp_modifystats [database].[owner].table_name, 
column_name | null,
	REMOVE_SKEW_FROM_DENSITY
	REMOVE_STICKINESS

Parameters

Examples

Usage

There are additional considerations when using sp_modifystats:
    • Allows the system administrator to modify the density values of a column—or columns—in sysstatistics.

    • Use optdiag to view a table’s statistics. See the Performance and Tuning Guide for more information about table density and using optdiag.

    • Any modification you make to the statistics with sp_modifystats is overwritten when you run update statistics. To make sure you are using the most recent statistical modifications, you should run sp_modifystats after you run update statistics.

    • Because sp_modifystats modifies information stored in the sysstatistics table, you should make a backup of statistics before execute running sp_modifystats in a production system.

    • You can use modify_default_selectivity only on an individual column, not a column group.
    • SAP ASE uses the default selectivity for modify_default_selectivity when an unknown constant prevents it from using a histogram to estimate selectivity of the respective predicate. The default selectivity for a search argument using inequality is 33%. inequality search arguments include columns for which there is an upper bound predicate or a lower bound predicate, but not both, and use the >=, <=, >, < range operators. The default selectivity for search arguments that include an inbetween search arguments is 25%. inbetween search arguments include columns that have both an upper bound predicate and a lower bound predicate, or use the between operator.

See also update statistics in Reference Manual: Commands.

Permissions

The permission checks for sp_modifystats differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with update statistics on the object or with manage any statistics privilege. You must have execute permission on the procedure.

Disabled

With granular permissions disabled, you must be a user with with update statistics on the object or sa_role. You must have execute permission on the procedure.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Tables used

sysstatistics