Auto Tuning Of Database Systems

2020. 11. 5. 01:44카테고리 없음



-->

Azure SQL Database is an automatically managed data service that constantly monitors your queries and identifies the action that you can perform to improve performance of your workload. You can review recommendations and manually apply them, or let Azure SQL Database automatically apply corrective actions - this is known as automatic tuning mode.

DBMS Auto-Tuning. The ability to collect, process, and analyze large amounts of data is paramount for being able to extrapolate new knowledge in business, scientific,.

Automatic tuning can be enabled at the server or the database level through the Azure portal, REST API calls and T-SQL commands.

Note

For Managed Instance, the supported option FORCE_LAST_GOOD_PLAN can be configured through T-SQL only. Portal based configuration and automatic index tuning options described in this article do not apply to Managed Instance.

  • To enable automatic tuning on a single database via T-SQL, connect to the database and execute the following query: ALTER DATABASE current SET AUTOMATICTUNING = AUTO INHERIT CUSTOM Setting automatic tuning to AUTO will apply Azure Defaults. Setting it to INHERIT, automatic tuning configuration will be inherited from the parent server.
  • If auto-tune is requested via API, then MIOpen will perform it and update PerfDb. This mode can be used for fine-tuning the MIOpen installation on the user's system. When MIOpen is in this mode, the applications that use it may take quite long to finish. SEARCH (3) MIOpen will perform auto-tune even if not requested via MIOpen API.

Note

Configuring Automatic tuning options through ARM (Azure Resource Manager) template is not supported at this time.

Enable automatic tuning on server

On the server level you can choose to inherit automatic tuning configuration from 'Azure Defaults' or not to inherit the configuration. Azure defaults are FORCE_LAST_GOOD_PLAN is enabled, CREATE_INDEX is enabled, and DROP_INDEX is disabled.

Database Tuning Wizard

Important

As of March, 2020 changes to Azure defaults for automatic tuning will take effect as follows:

  • New Azure defaults will be FORCE_LAST_GOOD_PLAN = enabled, CREATE_INDEX = disabled, and DROP_INDEX = disabled.
  • Existing servers with no automatic tuning preferences configured will be automatically configured to INHERIT the new Azure defaults. This applies to all customers currently having server settings for automatic tuning in an undefined state.
  • New servers created will automatically be configured to INHERIT the new Azure defaults (unlike earlier when automatic tuning configuration was in an undefined state upon new server creation).

Azure portal

To enable automatic tuning on Azure SQL Database logical server, navigate to the server in Azure portal and then select Automatic tuning in the menu.

Note

Please note that DROP_INDEX option at this time is not compatible with applications using partition switching and index hints and should not be enabled in these cases. Dropping unused indexes is not supported for Premium and Business Critical service tiers.

Select the automatic tuning options you want to enable and select Apply.

Automatic tuning options on a server are applied to all databases on this server. By default, all databases inherit configuration from their parent server, but this can be overridden and specified for each database individually.

REST API

Find out more about using REST API to enable Automatic tuning on a server, see SQL Server Automatic tuning UPDATE and GET HTTP methods.

Enable automatic tuning on an individual database

The Azure SQL Database enables you to individually specify the automatic tuning configuration for each database. On the database level you can choose to inherit automatic tuning configuration from the parent server, 'Azure Defaults' or not to inherit the configuration. Azure Defaults are set to FORCE_LAST_GOOD_PLAN is enabled, CREATE_INDEX is enabled, and DROP_INDEX is disabled.

Tip

The general recommendation is to manage the automatic tuning configuration at server level so the same configuration settings can be applied on every database automatically. Configure automatic tuning on an individual database only if you need that database to have different settings than others inheriting settings from the same server.

Techniques

Azure portal

Database Tuning Best Practices

To enable automatic tuning on a single database, navigate to the database in Azure portal and select Automatic tuning.

Individual automatic tuning settings can be separately configured for each database. You can manually configure an individual automatic tuning option, or specify that an option inherits its settings from the server.

Please note that DROP_INDEX option at this time is not compatible with applications using partition switching and index hints and should not be enabled in these cases.

Once you have selected your desired configuration, click Apply.

Rest API

Find out more about using REST API to enable Automatic tuning on a single database, see SQL Database Automatic tuning UPDATE and GET HTTP methods.

T-SQL

To enable automatic tuning on a single database via T-SQL, connect to the database and execute the following query:

Setting automatic tuning to AUTO will apply Azure Defaults. Setting it to INHERIT, automatic tuning configuration will be inherited from the parent server. Choosing CUSTOM, you will need to manually configure automatic tuning.

To configure individual automatic tuning options via T-SQL, connect to the database and execute the query such as this one:

Setting the individual tuning option to ON, will override any setting that database inherited and enable the tuning option. Setting it to OFF, will also override any setting that database inherited and disable the tuning option. Automatic tuning option, for which DEFAULT is specified, will inherit the automatic tuning configuration from the server level settings.

Important

In case of active geo-replication, Automatic tuning needs to be configured on the primary database only. Automatically applied tuning actions, such are for example index create or delete will be automatically replicated to the read-only secondary. Attempting to enable Automatic tuning via T-SQL on the read-only secondary will result in a failure as having a different tuning configuration on the read-only secondary is unsupported.

Find our more abut T-SQL options to configure Automatic tuning, see ALTER DATABASE SET Options (Transact-SQL) for SQL Database server.

Disabled by the system

Automatic tuning is monitoring all the actions it takes on the database and in some cases it can determine that automatic tuning can't properly work on the database. In this situation, tuning option will be disabled by the system. In most cases this happens because Query Store is not enabled or it's in read-only state on a specific database.

Permissions

As automatic tuning is Azure feature, to use it you will need to use Azure's built-in RBAC roles. Using SQL Authentication only will not be sufficient to use the feature from Azure portal.

To use automatic tuning, the minimum required permission to grant to the user is Azure's built-in SQL DB contributor role. You can also consider using higher privilege roles such are SQL Server Contributor, Contributor and Owner.

Configure automatic tuning e-mail notifications

See automatic tuning e-mail notifications guide.

Next steps

  • Read the Automatic tuning article to learn more about automatic tuning and how it can help you improve your performance.
  • See Performance recommendations for an overview of Azure SQL Database performance recommendations.
  • See Query Performance Insights to learn about viewing the performance impact of your top queries.

The DBMS_AUTO_SQLTUNE package is the interface for managing the Automatic SQL Tuning task. Unlike DBMS_SQLTUNE, the DBMS_AUTO_SQLTUNE package requires the DBA role.

The chapter contains the following topics:

    • Overview

    • Security Model

Using DBMS_AUTO_SQLTUNE

Overview

The DBMS_AUTO_SQLTUNE package is the interface to SQL Tuning Advisor (DBMS_SQLTUNE) when run within the Autotask framework. The database creates the automated system task SYS_AUTO_SQL_TUNING_TASK as part of the catalog scripts. This task automatically chooses a set of high-load SQL from AWR and runs the SQL Tuning Advisor on this SQL. The automated task performs the same comprehensive analysis as any other SQL Tuning task.

The automated task tests any SQL profiles it finds by executing both the old and new query plans. Automatic SQL Tuning differs from manual SQL tuning in one important way. If automatic implementation of SQL profiles is enabled (the default is disabled), then the database implements any SQL profiles that promise a great performance benefit. The implementation occurs at tuning time so that the database can immediately benefit from the new plan. You can enable or disable automatic implementation by using the SET_AUTO_TUNING_TASK_PARAMETER API to set the ACCEPT_SQL_PROFILES parameter.

In each maintenance window, the automated tuning task stores its results as a new execution. Each execution result has the same task name but a different execution name. Query the DBA_ADVISOR_EXECUTIONS view for information about task executions. Use the REPORT_AUTO_TUNING_TASK Function to view reports that span multiple executions.

Security Model

This package is available to users with the DBA role. For other users, you must grant the EXECUTE privilege on the package explicitly. Note that the EXECUTE_AUTO_TUNING_TASK procedure is an exception: only SYS can invoke it.

Users can call APIs in this package to control how the automatic tuning task behaves when it runs, such as enabling automatic SQL profile creation and configuring the total and per-SQL time limits under which the task runs. Because these settings affect the overall performance of the database, it may not be appropriate for all users with the ADVISOR privilege to have access to this package.

Summary of DBMS_AUTO_SQLTUNE Subprograms

Table 30-1 DBMS_AUTO_SQLTUNE Package Subprograms

SubprogramDescription

Executes the Automatic SQL Tuning task immediately (SYS only)

Displays a text report of the automatic tuning task's history

Changes a task parameter value for the daily automatic runs


EXECUTE_AUTO_TUNING_TASK Function & Procedure

This function and procedure executes the Automatic SQL Tuning task (SYS_AUTO_SQL_TUNING_TASK). Both the function and the procedure run in the context of a new task execution. The difference is that the function returns that new execution name. Note that only SYS can invoke this subprogram.

Parameters

Table 30-2 EXECUTE_TUNING_TASK Function & Procedure Parameters

ParameterDescription

execution_name

A name to qualify and identify an execution. If not specified, it is generated by the advisor and returned by function.

execution_params

List of parameters (name, value) for the specified execution. The execution parameters have effect only on the execution for which they are specified. They override the values for the parameters stored in the task (set through the SET_AUTO_TUNING_TASK_PARAMETER Procedures).

execution_desc

A 256-length string describing the execution


Auto Tuning Of Database Systems For Sale

Usage Notes

A tuning task can be executed multiple times without having to reset it.

Auto Tuning Of Database Systems Pdf

REPORT_AUTO_TUNING_TASK Function

This procedure displays the results of an Automatic SQL Tuning task.

Parameters

Table 30-3 REPORT_TUNING_TASK Function Parameters

ParameterDescription

begin_exec

Name of the beginning task execution to use. If NULL, the report is generated for the most recent task execution.

end_exec

Name of the ending task execution to use. If NULL, the report is generated for the most recent task execution.

type

Type of the report to produce. Possible values are TEXT which produces a text report.

level

Level of detail in the report:

  • BASIC: simple version of the report. Just show info about the actions taken by the advisor.

  • TYPICAL: show information about every statement analyzed, including requests not implemented.

  • ALL: highly detailed report level, also provides annotations about statements skipped over.

section

Section of the report to include:

  • SUMMARY: summary information

  • FINDINGS: tuning findings

  • PLAN: explain plans

  • INFORMATION: general information

  • ERROR: statements with errors

  • ALL: all sections

object_id

Advisor framework object id that represents a single statement to restrict reporting to. NULL for all statements. Only valid for reports that target a single execution.

result_limit

Maximum number of SQL statements to show in the report


Return Values

A CLOB containing the desired report.

SET_AUTO_TUNING_TASK_PARAMETER Procedures

This procedure updates the value of a SQL tuning parameter of type VARCHAR2 or NUMBER as used for the reserved auto tuning task, SYS_AUTO_SQL_TUNING_TASK.

Parameters

Table 30-4 SET_AUTO_TUNING_TASK_PARAMETER Procedure Parameters

Sound System Tuning

ParameterDescription

parameter

Name of the parameter to set. The possible tuning parameters that can be set by this procedure using the parameter in the form VARCHAR2:

  • MODE: tuning scope (comprehensive, limited)

  • USERNAME: username under which the statement is parsed

  • DAYS_TO_EXPIRE: number of days until the task is deleted

  • EXECUTION_DAYS_TO_EXPIRE: number of days until the tasks's executions is deleted (without deleting the task)

  • DEFAULT_EXECUTION_TYPE: the task defaults to this type of execution when none is specified by the EXECUTE_AUTO_TUNING_TASK Function & Procedure.

  • TIME_LIMIT: global time out (seconds)

  • LOCAL_TIME_LIMIT: per-statement time out (seconds)

  • TEST_EXECUTE: FULL/AUTO/OFF.

    * FULL - test-execute for as much time as necessary, up to the local time limit for the SQL (or the global task time limit if no SQL time limit is set)

    * AUTO - test-execute for an automatically-chosen time proportional to the tuning time

    * OFF - do not test-execute

  • BASIC_FILTER: basic filter for SQL tuning set

  • OBJECT_FILTER: object filter for SQL tuning set

  • PLAN_FILTER: plan filter for SQL tuning set (see SELECT_SQLSET for possible values)

  • RANK_MEASURE1: first ranking measure for SQL tuning set

  • RANK_MEASURE2: second possible ranking measure for SQL tuning set

  • RANK_MEASURE3: third possible ranking measure for SQL tuning set

  • RESUME_FILTER: a extra filter for SQL tuning sets besides BASIC_FILTER

  • SQL_LIMIT: maximum number of SQL statements to tune

  • SQL_PERCENTAGE: percentage filter of SQL tuning set statements

The following parameters are supported for the automatic tuning task only:

  • ACCEPT_SQL_PROFILES: TRUE/FALSE: whether the task should accept SQL profiles automatically

  • MAX_AUTO_SQL_PROFILES: maximum number of automatic SQL profiles allowed on the system, in sum

  • MAX_SQL_PROFILES_PER_EXEC: maximum number of SQL profiles that can be automatically implemented per execution of the task.

value

New value of the specified parameter

What Is Database Performance Tuning