Hello Simonas Solovjovas ,
Based on the information provided, it is difficult to determine the exact cause of the performance difference between the JDBC query and the Databricks SQL query. However, there are a few potential factors that could be contributing to the slower execution time of the Databricks SQL query:
- Databricks SQL may not be optimizing the subquery as efficiently as JDBC. You can try to analyze the execution plans for both queries to identify any differences
- It seems like in Databricks SQL query, the subquery might be causing a full table scan, leading to longer execution times. Consider rewriting the query to optimize the subquery execution.
- Another potential factor is the transfer of data between Databricks and SQL Server. Depending on the size of the data being transferred, this could be a significant bottleneck in the query execution.
Please check these and let me know for any additional questions.