Column ordering when querying a clustered table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 11:32 PM
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)?
- Labels:
-
Delta Lake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 08:35 AM
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?

