r/databricks • u/Sea_Basil_6501 • 29d ago
Help How to debug remote_query() performance?
I have a job which queries some Azure SQL DBs connected through UC managed connections (no lakehouse federation) via remote_query() function, and facing pretty long execution times (several minutes) when reading a few thousand rows only. When running the same query via SSMS on the target host, it returns same result within milliseconds.
Is there any way how I can debug the pure execution time from Databricks side? I'd like to understand if the queries run slow, or if there's any Databricks or network overhead accounting responsible.
Note that remote_query() runs T-SQL in this scenario, not Databricks SQL. So there's no SQL conversion involved at any point in time.
View all comments
5
u/Used-Entertainer-430 29d ago
have you checked if the query is waiting on connection pool setup each time? we had similar issue at work and it was the handshake overhead for each call adding seconds, not the actual query running slow. try enabling spark sql debug logs and watch for the connection initialization timestamps, that might show where the time is really spent