After looking at the "FETCH FIRST ... PERCENT" patch, I wonder if this patch should tweak estimates in some way. Currently, the cardinality estimate is the same as for plain LIMIT, using the requested number of rows. But let's say there are very few large groups - that will naturally increase the number of rows produced.
As an example, let's say the subplan produces 1M rows, and there are 1000 groups (when split according to the ORDER BY clause).
can we use ORDER BY column raw statistic in limit node reliably? because it seems to me it can be affected by other operation in a subplan like filter condition