cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Column ordering when querying a clustered table

oripsk
New Contributor

If I have a table which is clustered by (a, b, c) and I issue a query filtering on (b, c), will the query benefit from the optimization by the cluster of (a, b, c)?

 

 

1 REPLY 1

Retired_mod
Esteemed Contributor III

Hi @oripsk, When you query a table clustered by columns (a, b, c) and filter on (b, c), the query will not fully benefit from the clustering optimization. Clustering works best when the query filter includes the leading column(s) in the clustering order. In your case, since the filter does not include column ‘a’, the optimization benefits will be limited.

For optimal performance, it’s recommended to include the first clustered column in your query filter. This allows the query engine to effectively use the clustered index to reduce the amount of data scanned.

Is there a specific use case or dataset you’re working with that you’d like more advice on?