Re: Patch to support SEMI and ANTI join removal

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch to support SEMI and ANTI join removal
Date: 2014-08-17 06:29:37
Message-ID: CAApHDvo21-b+PU=sC9B1QiEG3YL4T919i4WjZfnfP6UPXS9nZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 10, 2014 at 11:48 PM, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:

>
> I've attached an updated version of the patch which fixes up some
> incorrect logic in the foreign key matching code, plus various comment
> improvements.
>

I've made a few updated to the patch to simplify some logic in the code
which analyses the join condition. The result is slightly faster code for
detecting either successful or unsuccessful join removal.

I've also been doing a little benchmarking of the overhead that this adds
to planning time for a handful of different queries.
With the queries I tested the overhead was between ~20 and ~423 nanoseconds
per SEMI or ANTI join, the 20 was for the earliest fast path out on an
unsuccessful removal and the 423 was for a successful removal. (tests done
on a 4 year old intel i5 laptop). This accounted for between 0.01% and 0.2%
of planning time for the tested queries. I was quite happy with this, but I
did manage to knock it down a little more with the
bms_get_singleton_v1.patch, which I've attached. This reduces the range to
between ~15 and ~409 nanoseconds, but probably this is going into micro
benchmark territory... so perhaps not worth the extra code...

With the benchmarks I just put semiorantijoin_is_removable() in a tight 1
million iteration loop and grabbed the total planning time for that, I then
compared this to an unpatched master's planning time after dividing the
time reported for the 1 million removals version by 1 million.

I didn't really find a good way to measure the extra overhead in actually
loading the foreign key constraints in get_relation_info()

Regards

David Rowley

Attachment Content-Type Size
anti_join_removal_benchmark.txt text/plain 3.7 KB
semianti_join_removal_7be0c95_2014-08-17.patch application/octet-stream 54.9 KB
bms_get_singleton_v1.patch application/octet-stream 4.9 KB
anti_join_removal_benchmark.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 20.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2014-08-17 14:26:52 Re: ALTER TABLESPACE MOVE command tag tweak
Previous Message Tomas Vondra 2014-08-16 21:09:11 Re: 9.5: Better memory accounting, towards memory-bounded HashAgg