Re: Pushing down sorted joins

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Pushing down sorted joins
Date: 2016-03-09 07:23:15
Message-ID: CAFjFpRfLeZJG0XfZs44kYzQ8eG-YsUaTRaGgV6nS+XnAhfAFAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> This patch needs to be rebased.
>
>
Done.

> + /*
> + * TODO: we should worry about EPQ path but should
> that path have
> + * pathkeys? I guess, that's not really important
> since it's just
> + * going to evaluate the join from whole-row
> references stuffed in the
> + * corresponding EPQ slots, for which the order doesn't
> matter.
> + */
>
> The pathkeys for the EPQ path don't matter. It'll only be called to
> recheck one single row, and there's only one order in which you can
> return one row.
>

Right. Removed the TODO

>
> - if (bms_equal(em->em_relids, rel->relids))
> + if (bms_is_subset(em->em_relids, rel->relids))
>
> Why do we need this?
>
>
The function find_em_expr_for_rel() find an equivalence member expression
that has all its Vars come from the given relation. It's not necessary that
it will have Vars from relids that are covered by the given relations. E.g.
in query SELECT A.c1, B.c2 FROM A join B ON ... ORDER BY A.c3, there will
be a single equivalence member A.c3 in the pathkeys and em_relids will
indicate only A. Hence instead of equal, (which used to be OK for single
relation join push-down) we have to use subset operation. We want an
equivalence members whose relids are subset of relids contained by given
relation.

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

Attachment Content-Type Size
pg_join_sort_pd_v3.patch text/x-diff 48.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2016-03-09 07:28:50 Re: [PROPOSAL] VACUUM Progress Checker.
Previous Message Haribabu Kommi 2016-03-09 06:16:59 Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Windows service is not starting so there’s message in log: FATAL: "could not create shared memory segment “Global/PostgreSQL.851401618”: Permission denied”