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

Method pgsql_cost_estimation

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

Source from the content-addressed store, hash-verified

139
140
141 def pgsql_cost_estimation(self, sql):
142 try:
143 #success, res = self.execute_sql('explain (FORMAT JSON, analyze) ' + sql)
144 success, res = self.execute_sql('explain (FORMAT JSON) ' + sql)
145 if success == 1:
146 cost = res[0][0][0]['Plan']['Total Cost']
147 return cost
148 else:
149 logging.error('pgsql_cost_estimation Fails!')
150 return 0
151 except Exception as error:
152 logging.error('pgsql_cost_estimation Exception', error)
153 return 0
154
155 def pgsql_actual_time(self, sql):
156 try:

Callers 1

cost_estimationMethod · 0.95

Calls 1

execute_sqlMethod · 0.95

Tested by

no test coverage detected