MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / mysql_cost_estimation

Method mysql_cost_estimation

bmtools/tools/database/utils/database.py:168–178  ·  view source on GitHub ↗
(self, sql)

Source from the content-addressed store, hash-verified

166 return -1
167
168 def mysql_cost_estimation(self, sql):
169 try:
170 success, res = self.execute_sql('explain format=json ' + sql)
171 if success == 1:
172 total_cost = self.get_mysql_total_cost(0, json.loads(res[0][0]))
173 return float(total_cost)
174 else:
175 return -1
176 except Exception as error:
177 logging.error('mysql_cost_estimation Exception', error)
178 return -1
179
180 def get_mysql_total_cost(self, total_cost, res):
181 if isinstance(res, dict):

Callers 1

cost_estimationMethod · 0.95

Calls 2

execute_sqlMethod · 0.95
get_mysql_total_costMethod · 0.95

Tested by

no test coverage detected