What is the significance of partitioning and bucketing in Spark, and how do they impact query performance?