QinXi-ai commented on PR #27299: URL: https://github.com/apache/datafusion/pull/27299#issuecomment-7381961776
Thanks, @alamb. I can see why Q10 alone was a hard sell for the added complexity. I replayed a published PostgreSQL query unchanged in DataFusion on the public Instacart dataset. It counts the distinct aisles and departments in each grocery order, then averages those counts across 3.35 million orders. [Original SQL](https://github.com/ksenia-ossi/product-affinity/blob/d941ec2c7542c5e1b9b6b77c527d99fd41e7d7f6/src/affinity/sql/explore.sql#L22-L33) What helped me understand the result was that 91% of the baskets contained items from multiple departments. Keeping the first department inline saves one hash-set insertion per basket, even when later items introduce other departments. The aisle count benefits in the same way. With the default DISTINCT optimizer settings, median time for the full query fell from 3.44 to 2.93 seconds at 4 partitions and from 2.15 to 1.80 seconds at 8. Peak memory reserved by the pool fell 14–17%. Both measures improved in every paired round, and both builds reproduced the [published results](https://github.com/ksenia-ossi/product-affinity/blob/d941ec2c7542c5e1b9b6b77c527d99fd41e7d7f6/reports/sql_exploration.md#L19-L25). That gives me a concrete reason to keep the first-value optimization. I’d be happy to revisit the logic that switches back to hashing if we can make it easier to follow. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
