Forum Discussion
Query folding
- 1 year ago
How to verify your query is folded (Databricks + Value.NativeQuery):
-
Value.NativeQuery already sends SQL to Databricks. Folding only matters for steps after that step.
-
In Power Query, right-click the last step >> View Native Query.
-
Clickable = still folded to SQL.
-
Greyed out = folding broke earlier.
-
-
Do a quick litmus test: add Keep Top Rows >> 5 (or filter a date). Recheck View Native Query.
-
If you see LIMIT 5 (or your WHERE clause) in the SQL, it’s folded.
-
-
Cross-check in Databricks >> SQL >> Query History while preview/refresh runs.
-
Your server log should show the final SQL with your filters. If it shows SELECT * and filters aren’t there, they were applied locally.
-
-
Remember: many steps break folding (e.g., Table.Buffer, custom M, merges with non-foldable sources). Put them after you’ve narrowed data.
-
Hi,
I'm facing the same issue, not sure if query folding works or not. I can see in query history the query runs in a few seconds but the incremental refresh is taking a lot (almost two hours).
Is this a known issue related to the Databricks connector?
Same issue, using the databricks connector, shows support for folding in UI, but incremental refresh says the query is not fully foldable. Disabling full folding in the incremental refresh setting in dataflow gen2 makes the run times go from 30m to 5hrs, at least for my workloads.
- Madalina28011 year agoAdvocate II
I managed to reduce the refresh duration from 2h to 20m after optimizing the dataset (I removed some high cardinality columns). In SSMS I saw the partitions were processed in 10m but the total refresh duration was 2h. It turned out that the problem was slow Power BI post-load processing. Even if the query runs fast on the source side in Databricks, the VertiPaq often recompresses column dictionaries across all partitions in the table, especially for high-cardinality or long text columns.