SqlTuningClient

class oci.database_management.SqlTuningClient(config, **kwargs)

Use the Database Management API to perform tasks such as obtaining performance and resource usage metrics for a fleet of Managed Databases or a specific Managed Database, creating Managed Database Groups, and running a SQL job on a Managed Database or Managed Database Group.

Methods

__init__(config, **kwargs) Creates a new service client
clone_sql_tuning_task(managed_database_id, …) Clones and runs a SQL tuning task in the database.
drop_sql_tuning_task(managed_database_id, …) Drops a SQL tuning task and its related results from the database.
get_execution_plan_stats_comparision(…) Retrieves a comparison of the existing SQL execution plan and a new plan.
get_sql_execution_plan(managed_database_id, …) Retrieves a SQL execution plan for the SQL being tuned.
get_sql_tuning_advisor_task_summary_report(…) Gets the summary report for the specified SQL Tuning Advisor task.
list_sql_tuning_advisor_task_findings(…) Gets an array of the details of the findings that match specific filters.
list_sql_tuning_advisor_task_recommendations(…) Gets the findings and possible actions for a given object in a SQL tuning task.
list_sql_tuning_advisor_tasks(…) Lists the SQL Tuning Advisor tasks for the specified Managed Database.
start_sql_tuning_task(managed_database_id, …) Starts a SQL tuning task for a given set of SQL statements from the active session history top SQL statements.
__init__(config, **kwargs)

Creates a new service client

Parameters:
  • config (dict) – Configuration keys and values as per SDK and Tool Configuration. The from_file() method can be used to load configuration from a file. Alternatively, a dict can be passed. You can validate_config the dict using validate_config()
  • service_endpoint (str) – (optional) The endpoint of the service to call using this client. For example https://iaas.us-ashburn-1.oraclecloud.com. If this keyword argument is not provided then it will be derived using the region in the config parameter. You should only provide this keyword argument if you have an explicit need to specify a service endpoint.
  • timeout (float or tuple(float, float)) – (optional) The connection and read timeouts for the client. The default values are connection timeout 10 seconds and read timeout 60 seconds. This keyword argument can be provided as a single float, in which case the value provided is used for both the read and connection timeouts, or as a tuple of two floats. If a tuple is provided then the first value is used as the connection timeout and the second value as the read timeout.
  • signer (AbstractBaseSigner) –

    (optional) The signer to use when signing requests made by the service client. The default is to use a Signer based on the values provided in the config parameter.

    One use case for this parameter is for Instance Principals authentication by passing an instance of InstancePrincipalsSecurityTokenSigner as the value for this keyword argument

  • retry_strategy (obj) –

    (optional) A retry strategy to apply to all calls made by this service client (i.e. at the client level). There is no retry strategy applied by default. Retry strategies can also be applied at the operation level by passing a retry_strategy keyword argument as part of calling the operation. Any value provided at the operation level will override whatever is specified at the client level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

  • circuit_breaker_strategy (obj) – (optional) A circuit breaker strategy to apply to all calls made by this service client (i.e. at the client level). This client uses DEFAULT_CIRCUIT_BREAKER_STRATEGY as default if no circuit breaker strategy is provided. The specifics of circuit breaker strategy are described here.
  • circuit_breaker_callback (function) – (optional) Callback function to receive any exceptions triggerred by the circuit breaker.
  • allow_control_chars – (optional) allow_control_chars is a boolean to indicate whether or not this client should allow control characters in the response object. By default, the client will not allow control characters to be in the response object.
clone_sql_tuning_task(managed_database_id, clone_sql_tuning_task_details, **kwargs)

Clones and runs a SQL tuning task in the database.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • clone_sql_tuning_task_details (oci.database_management.models.CloneSqlTuningTaskDetails) – (required) The detailed inputs required to clone a SQL tuning task.
  • opc_request_id (str) – (optional) The client request ID for tracing.
  • opc_retry_token (str) – (optional) A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations. For example, if a resource has been deleted and purged from the system, then a retry of the original creation request might be rejected.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningTaskReturn

Return type:

Response

Example:

Click here to see an example of how to use clone_sql_tuning_task API.

drop_sql_tuning_task(managed_database_id, drop_sql_tuning_task_details, **kwargs)

Drops a SQL tuning task and its related results from the database.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • drop_sql_tuning_task_details (oci.database_management.models.DropSqlTuningTaskDetails) – (required) The detailed inputs required to drop a SQL tuning task.
  • opc_request_id (str) – (optional) The client request ID for tracing.
  • opc_retry_token (str) – (optional) A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations. For example, if a resource has been deleted and purged from the system, then a retry of the original creation request might be rejected.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type None

Return type:

Response

Example:

Click here to see an example of how to use drop_sql_tuning_task API.

get_execution_plan_stats_comparision(managed_database_id, sql_tuning_advisor_task_id, sql_object_id, execution_id, **kwargs)

Retrieves a comparison of the existing SQL execution plan and a new plan. A SQL tuning task may suggest a new execution plan for a SQL, and this API retrieves the comparison report of the statistics of the two plans.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • sql_tuning_advisor_task_id (int) –

    (required) The SQL tuning task identifier. This is not the OCID.

  • sql_object_id (int) –

    (required) The SQL object ID for the SQL tuning task. This is not the OCID.

  • execution_id (int) –

    (required) The execution ID for an execution of a SQL tuning task. This is not the OCID.

  • opc_request_id (str) – (optional) The client request ID for tracing.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type ExecutionPlanStatsComparision

Return type:

Response

Example:

Click here to see an example of how to use get_execution_plan_stats_comparision API.

get_sql_execution_plan(managed_database_id, sql_tuning_advisor_task_id, sql_object_id, attribute, **kwargs)

Retrieves a SQL execution plan for the SQL being tuned.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • sql_tuning_advisor_task_id (int) –

    (required) The SQL tuning task identifier. This is not the OCID.

  • sql_object_id (int) –

    (required) The SQL object ID for the SQL tuning task. This is not the OCID.

  • attribute (str) –

    (required) The attribute of the SQL execution plan.

    Allowed values are: “ORIGINAL”, “ORIGINAL_WITH_ADJUSTED_COST”, “USING_SQL_PROFILE”, “USING_NEW_INDICES”

  • opc_request_id (str) – (optional) The client request ID for tracing.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningAdvisorTaskSqlExecutionPlan

Return type:

Response

Example:

Click here to see an example of how to use get_sql_execution_plan API.

get_sql_tuning_advisor_task_summary_report(managed_database_id, sql_tuning_advisor_task_id, **kwargs)

Gets the summary report for the specified SQL Tuning Advisor task.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • sql_tuning_advisor_task_id (int) –

    (required) The SQL tuning task identifier. This is not the OCID.

  • search_period (str) –

    (optional) How far back the API will search for begin and end exec id. Unused if neither exec ids nor time filter query params are supplied. This is applicable only for Auto SQL Tuning tasks.

    Allowed values are: “LAST_24HR”, “LAST_7DAY”, “LAST_31DAY”, “SINCE_LAST”, “ALL”

  • time_greater_than_or_equal_to (datetime) – (optional) The optional greater than or equal to query parameter to filter the timestamp. This is applicable only for Auto SQL Tuning tasks.
  • time_less_than_or_equal_to (datetime) – (optional) The optional less than or equal to query parameter to filter the timestamp. This is applicable only for Auto SQL Tuning tasks.
  • begin_exec_id_greater_than_or_equal_to (int) – (optional) The optional greater than or equal to filter on the execution ID related to a specific SQL Tuning Advisor task. This is applicable only for Auto SQL Tuning tasks.
  • end_exec_id_less_than_or_equal_to (int) – (optional) The optional less than or equal to query parameter to filter on the execution ID related to a specific SQL Tuning Advisor task. This is applicable only for Auto SQL Tuning tasks.
  • opc_request_id (str) – (optional) The client request ID for tracing.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningAdvisorTaskSummaryReport

Return type:

Response

Example:

Click here to see an example of how to use get_sql_tuning_advisor_task_summary_report API.

list_sql_tuning_advisor_task_findings(managed_database_id, sql_tuning_advisor_task_id, **kwargs)

Gets an array of the details of the findings that match specific filters.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • sql_tuning_advisor_task_id (int) –

    (required) The SQL tuning task identifier. This is not the OCID.

  • begin_exec_id (int) – (optional) The optional greater than or equal to filter on the execution ID related to a specific SQL Tuning Advisor task.
  • end_exec_id (int) – (optional) The optional less than or equal to query parameter to filter on the execution ID related to a specific SQL Tuning Advisor task.
  • search_period (str) –

    (optional) The search period during which the API will search for begin and end exec id, if not supplied. Unused if beginExecId and endExecId optional query params are both supplied.

    Allowed values are: “LAST_24HR”, “LAST_7DAY”, “LAST_31DAY”, “SINCE_LAST”, “ALL”

  • finding_filter (str) –

    (optional) The filter used to display specific findings in the report.

    Allowed values are: “none”, “FINDINGS”, “NOFINDINGS”, “ERRORS”, “PROFILES”, “INDICES”, “STATS”, “RESTRUCTURE”, “ALTERNATIVE”, “AUTO_PROFILES”, “OTHER_PROFILES”

  • stats_hash_filter (str) – (optional) The hash value of the object for the statistic finding search.
  • index_hash_filter (str) – (optional) The hash value of the index table name.
  • sort_by (str) –

    (optional) The possible sortBy values of an object’s recommendations.

    Allowed values are: “DBTIME_BENEFIT”, “PARSING_SCHEMA”, “SQL_ID”, “STATS”, “PROFILES”, “SQL_BENEFIT”, “DATE”, “INDICES”, “RESTRUCTURE”, “ALTERNATIVE”, “MISC”, “ERROR”, “TIMEOUTS”

  • sort_order (str) –

    (optional) The option to sort information in ascending (‘ASC’) or descending (‘DESC’) order. Descending order is the default order.

    Allowed values are: “ASC”, “DESC”

  • page (str) – (optional) The page token representing the page from where the next set of paginated results are retrieved. This is usually retrieved from a previous list call.
  • limit (int) – (optional) The maximum number of records returned in the paginated response.
  • opc_request_id (str) – (optional) The client request ID for tracing.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningAdvisorTaskFindingCollection

Return type:

Response

Example:

Click here to see an example of how to use list_sql_tuning_advisor_task_findings API.

list_sql_tuning_advisor_task_recommendations(managed_database_id, sql_tuning_advisor_task_id, sql_object_id, execution_id, **kwargs)

Gets the findings and possible actions for a given object in a SQL tuning task. The task ID and object ID are used to retrieve the findings and recommendations.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • sql_tuning_advisor_task_id (int) –

    (required) The SQL tuning task identifier. This is not the OCID.

  • sql_object_id (int) –

    (required) The SQL object ID for the SQL tuning task. This is not the OCID.

  • execution_id (int) –

    (required) The execution ID for an execution of a SQL tuning task. This is not the OCID.

  • sort_by (str) –

    (optional) The possible sortBy values of an object’s recommendations.

    Allowed values are: “RECOMMENDATION_TYPE”, “BENEFIT”

  • sort_order (str) –

    (optional) The option to sort information in ascending (‘ASC’) or descending (‘DESC’) order. Descending order is the default order.

    Allowed values are: “ASC”, “DESC”

  • page (str) – (optional) The page token representing the page from where the next set of paginated results are retrieved. This is usually retrieved from a previous list call.
  • limit (int) – (optional) The maximum number of records returned in the paginated response.
  • opc_request_id (str) – (optional) The client request ID for tracing.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningAdvisorTaskRecommendationCollection

Return type:

Response

Example:

Click here to see an example of how to use list_sql_tuning_advisor_task_recommendations API.

list_sql_tuning_advisor_tasks(managed_database_id, **kwargs)

Lists the SQL Tuning Advisor tasks for the specified Managed Database.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • name (str) – (optional) The optional query parameter to filter the SQL Tuning Advisor task list by name.
  • status (str) –

    (optional) The optional query parameter to filter the SQL Tuning Advisor task list by status.

    Allowed values are: “INITIAL”, “EXECUTING”, “INTERRUPTED”, “COMPLETED”, “ERROR”

  • time_greater_than_or_equal_to (datetime) – (optional) The optional greater than or equal to query parameter to filter the timestamp.
  • time_less_than_or_equal_to (datetime) – (optional) The optional less than or equal to query parameter to filter the timestamp.
  • page (str) – (optional) The page token representing the page from where the next set of paginated results are retrieved. This is usually retrieved from a previous list call.
  • limit (int) – (optional) The maximum number of records returned in the paginated response.
  • sort_by (str) –

    (optional) The option to sort the SQL Tuning Advisor task summary data.

    Allowed values are: “NAME”, “START_TIME”

  • sort_order (str) –

    (optional) The option to sort information in ascending (‘ASC’) or descending (‘DESC’) order. Descending order is the default order.

    Allowed values are: “ASC”, “DESC”

  • opc_request_id (str) – (optional) The client request ID for tracing.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningAdvisorTaskCollection

Return type:

Response

Example:

Click here to see an example of how to use list_sql_tuning_advisor_tasks API.

start_sql_tuning_task(managed_database_id, start_sql_tuning_task_details, **kwargs)

Starts a SQL tuning task for a given set of SQL statements from the active session history top SQL statements.

Parameters:
  • managed_database_id (str) –

    (required) The OCID of the Managed Database.

  • start_sql_tuning_task_details (oci.database_management.models.StartSqlTuningTaskDetails) – (required) The detailed inputs required to start a SQL tuning task.
  • opc_request_id (str) – (optional) The client request ID for tracing.
  • opc_retry_token (str) – (optional) A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations. For example, if a resource has been deleted and purged from the system, then a retry of the original creation request might be rejected.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. This operation will not retry by default, users can also use the convenient DEFAULT_RETRY_STRATEGY provided by the SDK to enable retries for it. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

  • allow_control_chars (bool) – (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings
Returns:

A Response object with data of type SqlTuningTaskReturn

Return type:

Response

Example:

Click here to see an example of how to use start_sql_tuning_task API.