Home › Interview Questions › If a column 'id' is present in 700 partitions, how…

If a column 'id' is present in 700 partitions, how would you reduce the number of partitions read when filtering on that id?

🟡 Medium Conceptual Junior level
1Times asked
Aug 2026Last seen
Aug 2026First seen

💡 Model Answer

When filtering on a column that is not the partition key, Spark will normally scan all partitions, which is expensive if there are many partitions. To reduce the scan, you can: 1) Repartition or bucket the data on the 'id' column so that all rows with the same id reside in the same partition; this enables partition pruning. 2) Use a broadcast join if the 'id' column is small enough: broadcast the small dataset and join locally. 3) Store the data in a format that supports column pruning and predicate pushdown (e.g., Parquet) and ensure the filter is applied before the read. 4) If the data is highly skewed, consider using a custom partitioner or salting the key to spread the load. By aligning the partitioning strategy with the filter column, Spark can skip irrelevant partitions and dramatically reduce I/O.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500