Re: Top-N sorts verses parallelism

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Top-N sorts verses parallelism
Date: 2017-12-19 11:54:38
Message-ID: CAEepm=1UH1wZ88kVrPrxg3YmSNoCmV3n2fSvBwDvS1f8Z91UYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 18, 2017 at 9:29 AM, Robert Haas <robertmhaas(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2017-12-19 12:02:32 Re: Top-N sorts verses parallelism
Previous Message Pavel Stehule 2017-12-19 11:54:24 Re: Notes about Pl/PgSQL assignment performance