On Mon, Dec 18, 2017 at 9:29 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> I went through the callers to create_sort_path and the only one that
> looks like it can pass a limit is the one you and Jeff already
> identified. So I think the question is just whether
> create_gather_merge_path needs a similar fix.
I might be missing something, but it looks like there are no cases
where we have a limit_tuples value we could use AND we're relying on
create_gather_merge_path's own ability to create sort paths. So I
suspect there is no reason to change create_gather_merge_path itself
to deal with tuple limits. I looked at each of its callers:
1. create_ordered_paths is the case the patch posted earlier covers:
it has a useful limit_tuples value but it creates the sort path itself
first, so there is no need for create_gather_merge_path to be aware of
it.
2. create_grouping_paths doesn't have limit_tuples value because
grouping always inhibits limits.
3. generate_gather_paths is in turn called by:
3.1. standard_joinsearch can't use limits (at least in general) since
it's dealing with a join.
3.2. geco's merge_clump is also about joins, so ditto.
3.3. set_rel_pathlist will consider only pathkeys from existing index
scans that set_plain_rel_pathlist found, not creating new pathkeys by
sorting.
--
Thomas Munro
http://www.enterprisedb.com