Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/azure-cli/azure/cli/command_modules/rdbms/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ def call(*args, **kwargs):

def get_index_tuning_settings_map():
return {
'analysis-interval': 'index_tuning.analysis_interval',
'max-columns-per-index': 'index_tuning.max_columns_per_index',
'max-index-count': 'index_tuning.max_index_count',
'max-indexes-per-table': 'index_tuning.max_indexes_per_table',
'max-queries-per-database': 'index_tuning.max_queries_per_database',
'max-regression-factor': 'index_tuning.max_regression_factor',
'max-total-size-factor': 'index_tuning.max_total_size_factor',
'min-improvement-factor': 'index_tuning.min_improvement_factor',
'analysis_interval': 'index_tuning.analysis_interval',
'max_columns_per_index': 'index_tuning.max_columns_per_index',
'max_index_count': 'index_tuning.max_index_count',
'max_indexes_per_table': 'index_tuning.max_indexes_per_table',
'max_queries_per_database': 'index_tuning.max_queries_per_database',
'max_regression_factor': 'index_tuning.max_regression_factor',
'max_total_size_factor': 'index_tuning.max_total_size_factor',
'min_improvement_factor': 'index_tuning.min_improvement_factor',
'mode': 'index_tuning.mode',
'unused-dml-per-table': 'index_tuning.unused_dml_per_table',
'unused-min-period': 'index_tuning.unused_min_period',
'unused-reads-per-table': 'index_tuning.unused_reads_per_table'
'unused_dml_per_table': 'index_tuning.unused_dml_per_table',
'unused_min_period': 'index_tuning.unused_min_period',
'unused_reads_per_table': 'index_tuning.unused_reads_per_table'
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def load_flexibleserver_command_table(self, _):
with self.command_group('postgres flexible-server index-tuning', postgres_flexible_config_sdk,
client_factory=cf_postgres_flexible_config) as g:
g.custom_command('update', 'index_tuning_update', custom_command_type=flexible_servers_custom_postgres)
g.custom_command('show', 'index_tuning_show', custom_command_type=flexible_servers_custom_postgres)
g.custom_show_command('show', 'index_tuning_show', custom_command_type=flexible_servers_custom_postgres)
g.custom_command('list-settings', 'index_tuning_settings_list', custom_command_type=flexible_servers_custom_postgres)
g.custom_command('show-settings', 'index_tuning_settings_get', custom_command_type=flexible_servers_custom_postgres)
g.custom_command('set-settings', 'index_tuning_settings_set', custom_command_type=flexible_servers_custom_postgres)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1623,23 +1623,29 @@ def index_tuning_update(cmd, client, resource_group_name, server_name, index_tun
value = "report"
_update_parameters(cmd, client, server_name, configuration_name, resource_group_name, source, value)
configuration_name = "pg_qs.query_capture_mode"
value = "all"
return _update_parameters(cmd, client, server_name, configuration_name, resource_group_name, source, value)
query_capture_mode_configuration = client.get(resource_group_name, server_name, configuration_name)

logger.warning("Disabling index tuning for the server.")
configuration_name = "index_tuning.mode"
value = "off"
return _update_parameters(cmd, client, server_name, configuration_name, resource_group_name, source, value)
if query_capture_mode_configuration.value.lower() == "none":
value = "all"
_update_parameters(cmd, client, server_name, configuration_name, resource_group_name, source, value)
logger.warning("Index tuning is enabled for the server.")
else:
logger.warning("Disabling index tuning for the server.")
configuration_name = "index_tuning.mode"
value = "off"
_update_parameters(cmd, client, server_name, configuration_name, resource_group_name, source, value)
logger.warning("Index tuning is disabled for the server.")


def index_tuning_show(cmd, client, resource_group_name, server_name):
def index_tuning_show(client, resource_group_name, server_name):
validate_resource_group(resource_group_name)
index_tuning_configuration = client.get(resource_group_name, server_name, "index_tuning.mode")
query_capture_mode_configuration = client.get(resource_group_name, server_name, "pg_qs.query_capture_mode")

if index_tuning_configuration.value.lower() == "report":
print("Index tuning is enabled for the server.")
if index_tuning_configuration.value.lower() == "report" and query_capture_mode_configuration != "none":
logger.warning("Index tuning is enabled for the server.")
else:
print("Index tuning is not enabled for the server.")
logger.warning("Index tuning is disabled for the server.")


def index_tuning_settings_list(cmd, client, resource_group_name, server_name):
Expand Down
Loading