diff --git a/.changes/unreleased/Under the Hood-20240621-150837.yaml b/.changes/unreleased/Under the Hood-20240621-150837.yaml new file mode 100644 index 00000000..fab070c7 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20240621-150837.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Fix query timer resolution +time: 2024-06-21T15:08:37.43527-04:00 +custom: + Author: peterallenwebb + Issue: "246" diff --git a/dbt/adapters/events/types.py b/dbt/adapters/events/types.py index 7d98269d..47c48da6 100644 --- a/dbt/adapters/events/types.py +++ b/dbt/adapters/events/types.py @@ -190,7 +190,7 @@ def code(self) -> str: return "E017" def message(self) -> str: - return f"SQL status: {self.status} in {self.elapsed} seconds" + return f"SQL status: {self.status} in {self.elapsed:.3f} seconds" class SQLCommit(DebugLevel): diff --git a/dbt/adapters/sql/connections.py b/dbt/adapters/sql/connections.py index f48c043d..4d450c88 100644 --- a/dbt/adapters/sql/connections.py +++ b/dbt/adapters/sql/connections.py @@ -86,7 +86,8 @@ def add_query( node_info=get_node_info(), ) ) - pre = time.time() + + pre = time.perf_counter() cursor = connection.handle.cursor() cursor.execute(sql, bindings) @@ -94,7 +95,7 @@ def add_query( fire_event( SQLQueryStatus( status=str(self.get_response(cursor)), - elapsed=round((time.time() - pre)), + elapsed=time.perf_counter() - pre, node_info=get_node_info(), ) )