Re: Top-N sorts verses parallelism - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Top-N sorts verses parallelism
Date
Msg-id CAEepm=1UH1wZ88kVrPrxg3YmSNoCmV3n2fSvBwDvS1f8Z91UYQ@mail.gmail.com
Whole thread Raw
In response to Re: Top-N sorts verses parallelism  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Top-N sorts verses parallelism  (Amit Kapila <amit.kapila16@gmail.com>)
Re: Top-N sorts verses parallelism  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Notes about Pl/PgSQL assignment performance
Next
From: Amit Kapila
Date:
Subject: Re: Top-N sorts verses parallelism