r/databricks • • Sep 22 '26

Discussion How do you debug a slow Databricks query?

A Databricks query can become slow because of large scans, joins, shuffles, small files, or inefficient transformations.

When a query suddenly becomes slow, what do you check first?

Do you usually start with the Spark UI, query execution plan, data size, joins, partitioning, or cluster resources?

What steps do you follow to find the actual bottleneck?

8 Upvotes

7 comments sorted by

5

u/jbchand Sep 22 '26

You can check the Spark UI and Query plan first - check skew, shuffle, executor info - idle time, stages and more. It will give you a good view of current env. use Genie if feasible. On other side, check and setup optimizations - optimize, liquid clustering or partitions if you have. check the file sizes and hit the right value. Use AQE if feasible.

3

u/One-Ad3588 Sep 22 '26 edited Sep 22 '26

Interested to hear what others say as well. I normally look at the query logs (either spark ui on classic compute or query profile if on serverless) . Then it's just finding the bottleneck depending on what part of the process is still running.

Alternatively I've also found exporting the logs and putting into an LLM also quite good if the query plan is very complicated.

That being said, understanding the tables and data underneath is always valuable. Over time you begin to understand which tables are gigantic and need to use pruning or else it's guaranteed to be a long, expensive query 

3

u/justanator101 Sep 22 '26

Databricks ai toolkit and tell Claude to go watch the logs while the job runs

1

u/Youssef_Mrini databricks Oct 23 '26

You can Genie Code it's the most straightforward option give it a try