[query-perf-log] Add execution time for debug opt in frappe.db.sql (#5592)
* [query-perf-log] Add execution time for debug opt in frappe.db.sql * Update database.py
This commit is contained in:
parent
80c0b45e0a
commit
4d96fcc557
1 changed files with 10 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import datetime
|
|||
import frappe
|
||||
import frappe.defaults
|
||||
import frappe.async
|
||||
from time import time
|
||||
import re
|
||||
import frappe.model.meta
|
||||
from frappe.utils import now, get_datetime, cstr, cast_fieldtype
|
||||
|
|
@ -172,6 +173,9 @@ class Database:
|
|||
|
||||
# execute
|
||||
try:
|
||||
if debug:
|
||||
time_start = time()
|
||||
|
||||
if values!=():
|
||||
if isinstance(values, dict):
|
||||
values = dict(values)
|
||||
|
|
@ -204,6 +208,12 @@ class Database:
|
|||
|
||||
self._cursor.execute(query)
|
||||
|
||||
if debug:
|
||||
frappe.errprint("\n--- query stats start ---\n")
|
||||
time_end = time()
|
||||
frappe.errprint(("Execution time: {0} sec").format(round(time_end - time_start, 2)))
|
||||
frappe.errprint("\n--- query stats end ---\n")
|
||||
|
||||
except Exception as e:
|
||||
if ignore_ddl and e.args[0] in (ER.BAD_FIELD_ERROR, ER.NO_SUCH_TABLE,
|
||||
ER.CANT_DROP_FIELD_OR_KEY):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue