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

Method pgsql_cost_estimation

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

Source from the content-addressed store, hash-verified

162 return 0
163
164 def pgsql_cost_estimation(self, sql):
165 try:
166 #success, res = self.execute_sql('explain (FORMAT JSON, analyze) ' + sql)
167 success, res = self.execute_sql('explain (FORMAT JSON) ' + sql)
168 if success == 1:
169 cost = res[0][0][0]['Plan']['Total Cost']
170 return cost
171 else:
172 logging.error('pgsql_cost_estimation Fails!')
173 return 0
174 except Exception as error:
175 logging.error('pgsql_cost_estimation Exception', error)
176 return 0
177
178 def pgsql_actual_time(self, sql):
179 try:

Callers 1

cost_estimationMethod · 0.95

Calls 1

execute_sqlMethod · 0.95

Tested by

no test coverage detected