From 91a7306a8857cc832e944c1bf060a3c85759717c Mon Sep 17 00:00:00 2001 From: Eukanj827 Date: Mon, 15 Aug 2022 10:08:06 +0800 Subject: [PATCH] Update execute_factory.py --- .../index_advisor/dao/execute_factory.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gausskernel/dbmind/tools/components/index_advisor/dao/execute_factory.py b/src/gausskernel/dbmind/tools/components/index_advisor/dao/execute_factory.py index 88ffade7f..287ef86e6 100644 --- a/src/gausskernel/dbmind/tools/components/index_advisor/dao/execute_factory.py +++ b/src/gausskernel/dbmind/tools/components/index_advisor/dao/execute_factory.py @@ -13,10 +13,9 @@ import re -#class name: -#description: -#methods: -#note: +#class name: IndexInfo +#description: Define information about table indexes +#methods: __init__ #date: 2022/8/10 #contact: 1865997821 @@ -30,7 +29,7 @@ class IndexInfo: self.primary_key = False self.redundant_obj = [] -#class name: +#class name: ExecuteFactory #description: #methods: #note: @@ -47,11 +46,11 @@ class ExecuteFactory: self.max_index_storage = max_index_storage self.multi_node = multi_node +# Record redundant indexes @staticmethod def record_redundant_indexes(cur_table_indexes, redundant_indexes): cur_table_indexes = sorted(cur_table_indexes, key=lambda index_obj: len(index_obj.columns.split(','))) - # record redundant indexes for pos, index in enumerate(cur_table_indexes[:-1]): is_redundant = False for candidate_index in cur_table_indexes[pos + 1:]: @@ -63,6 +62,7 @@ class ExecuteFactory: if is_redundant: redundant_indexes.append(index) +#Match the name of the table against the index of the query @staticmethod def match_table_name(table_name, query_index_dict): for elem in query_index_dict.keys(): @@ -77,6 +77,7 @@ class ExecuteFactory: return False, table_name return True, table_name +#Retrieves a valid index based on the regular expression, adding the corresponding index and empty element if none exists @staticmethod def get_valid_indexes(record, hypoid_table_column, valid_indexes): tokens = record.split(' ') @@ -99,6 +100,7 @@ class ExecuteFactory: if columns not in valid_indexes[table_name]: valid_indexes[table_name].append((columns, index_type)) +#Record invalid SQL statements and returns the corresponding help information that matches the corresponding SQL statement @staticmethod def record_ineffective_negative_sql(candidate_index, obj, ind): cur_table = candidate_index.table @@ -136,6 +138,7 @@ class ExecuteFactory: candidate_index.ineffective_pos.append(ind) candidate_index.total_sql_num += obj.frequency +#Returns the last input and the corresponding result @staticmethod def match_last_result(table_name, index_column, history_indexes, history_invalid_indexes): for column in history_indexes.get(table_name, dict()): @@ -153,6 +156,7 @@ class ExecuteFactory: if not history_indexes[table_name]: del history_indexes[table_name] +#Correcting SQL statements @staticmethod def make_single_advisor_sql(ori_sql): sql = 'select gs_index_advise(\''