On Thu, 11 Jun 2026 at 03:50, Ilia Evdokimov <[email protected]> wrote: > In [0], a question was raised whether we should expose IncrementalSort group > estimation in EXPLAIN, as we did for Memoize. Knowing the estimated number of > groups helps understand why the planner chose IncrementalSort whether a bad > estimate is to blame for a sub-optimal plan. > [0]: > https://www.postgresql.org/message-id/6642af90-561c-4f0c-9d5b-7e288e6e7f84%40gmail.com
I think it makes sense to have this information in EXPLAIN. A couple of things about the patch: 1. I think the new est_input_groups field should be Cardinality rather than double. Various other Path types and Plan nodes call this "numGroups". I don't see any reason to deviate from that. 2. The header comment for cost_incremental_sort needs to be updated to mention that p_input_groups may be passed as non-NULL to provide the caller with the estimated number of sort groups. David
