berkaysynnada commented on PR #17684: URL: https://github.com/apache/datafusion/pull/17684#issuecomment-3316177281
``` DataFusion CLI v50.0.0 > WITH source AS ( SELECT 1 AS n, '' AS a1, '' AS a2, '' AS a3, '' AS a4, '' AS a5, '' AS a6, '' AS a7, '' AS a8, '' AS a9, '' AS a10, '' AS a11, '' AS a12, '' AS a13, '' AS a14, '' AS a15, '' AS a16, '' AS a17, '' AS a18, '' AS a19, '' AS a20, '' AS a21, '' AS a22, '' AS a23, '' AS a24, '' AS a25, '' AS a26, '' AS a27, '' AS a28, '' AS a29, '' AS a30, '' AS a31, '' AS a32, '' AS a33, '' AS a34, '' AS a35, '' AS a36, '' AS a37, '' AS a38, '' AS a39, '' AS a40 ) SELECT sum(n) OVER (PARTITION BY a1, a2, a3, a4 ) FROM source; +----------------------------------------------------------------------------------------------------------------------------------+ | sum(source.n) PARTITION BY [source.a1, source.a2, source.a3, source.a4] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING | +----------------------------------------------------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------------------------------------------------+ 1 row(s) fetched. Elapsed 0.039 seconds. > WITH source AS ( SELECT 1 AS n, '' AS a1, '' AS a2, '' AS a3, '' AS a4, '' AS a5, '' AS a6, '' AS a7, '' AS a8, '' AS a9, '' AS a10, '' AS a11, '' AS a12, '' AS a13, '' AS a14, '' AS a15, '' AS a16, '' AS a17, '' AS a18, '' AS a19, '' AS a20, '' AS a21, '' AS a22, '' AS a23, '' AS a24, '' AS a25, '' AS a26, '' AS a27, '' AS a28, '' AS a29, '' AS a30, '' AS a31, '' AS a32, '' AS a33, '' AS a34, '' AS a35, '' AS a36, '' AS a37, '' AS a38, '' AS a39, '' AS a40 ) SELECT sum(n) OVER (PARTITION BY a1, a2, a3, a4, a5 ) FROM source; +---------------------------------------------------------------------------------------------------------------------------------------------+ | sum(source.n) PARTITION BY [source.a1, source.a2, source.a3, source.a4, source.a5] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING | +---------------------------------------------------------------------------------------------------------------------------------------------+ | 1 | +---------------------------------------------------------------------------------------------------------------------------------------------+ 1 row(s) fetched. Elapsed 0.018 seconds. ``` I missed the case where there are no ordering constraints. In that scenario, ordering_satisfy() returns true for nearly all combinations, so we were still keeping O(4^n) orderings despite pruning. I've now updated the approach as greedy. 1) For each partition column, try 4 sort options and pick the first that works 2) Move to the next column only with the chosen option 3) Stop immediately if any column has no valid option Can you check this updated version @findepi ? -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org