diff options
Diffstat (limited to 'odoo/sql_db.py')
| -rw-r--r-- | odoo/sql_db.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/odoo/sql_db.py b/odoo/sql_db.py index ae1db0d6436..afa396148f0 100644 --- a/odoo/sql_db.py +++ b/odoo/sql_db.py @@ -217,10 +217,9 @@ class Cursor(object): raise ValueError("SQL query parameters should be a tuple, list or dict; got %r" % (params,)) if self.sql_log: - now = time.time() encoding = psycopg2.extensions.encodings[self.connection.encoding] _logger.debug("query: %s", self._obj.mogrify(query, params).decode(encoding, 'replace')) - + now = time.time() try: params = params or None res = self._obj.execute(query, params) @@ -231,10 +230,14 @@ class Cursor(object): # simple query count is always computed self.sql_log_count += 1 + delay = (time.time() - now) + if hasattr(threading.current_thread(), 'query_count'): + threading.current_thread().query_count += 1 + threading.current_thread().query_time += delay # advanced stats only if sql_log is enabled if self.sql_log: - delay = (time.time() - now) * 1E6 + delay *= 1E6 res_from = re_from.match(query.lower()) if res_from: |
