Re: anti-join chosen even when slower than old plan - Mailing list pgsql-performance

From Tom Lane
Subject Re: anti-join chosen even when slower than old plan
Date
Msg-id 4061.1289403202@sss.pgh.pa.us
Whole thread Raw
In response to Re: anti-join chosen even when slower than old plan  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-performance
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> In principle, the old-style plan ought to be equivalent to a
>> nestloop antijoin with a seqscan of DbTranLogRecord on the outside
>> and an indexscan of DbTranRepository on the inside.  Can you force
>> it to choose such a plan by setting enable_mergejoin off (and
>> maybe enable_hashjoin too)?

> Well, I got what I think is the equivalent plan by adding OFFSET 0
> to the subquery:

No, that *is* the old-style plan (plus a useless Limit node, which will
surely make it marginally slower).  My point was that a nestloop
antijoin plan should have the same access pattern and hence very similar
performance, maybe even a little better due to not having the SubPlan
machinery in there.

> But wait -- it turns out that this pain was self-inflicted.  Based
> on heavy testing of the interactive queries which users run against
> this database we tuned the database for "fully-cached" settings,
> with both random_page_cost and _seq_page_cost at 0.1.

Ah.  So it was underestimating the cost of the full-table indexscans,
and my guess about nonsequential application of the delete actions
wasn't the right guess.  The merge antijoin does seem like it should be
the fastest way of doing such a large join, so I think the problem is
solved.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: anti-join chosen even when slower than old plan
Next
From: Robert Haas
Date:
Subject: Re: anti-join chosen even when slower than old plan