Re: Problems with plan estimates in postgres_fdw

Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>

From: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
To: Antonin Houska <ah@cybertec.at>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andrew Gierth <andrew@tao11.riddles.org.uk>, pgsql-hackers@postgresql.org
Date: 2019-03-27T08:15:02Z
Lists: pgsql-hackers

Attachments

(2019/03/26 21:41), Etsuro Fujita wrote:
> (2019/03/20 20:47), Etsuro Fujita wrote:
>> Attached is an updated version of the patch set.
>
> One thing I noticed while self-reviewing the patch for UPPERREL_FINAL
> is: the previous versions of the patch don't show EPQ plans in EXPLAIN,
> as shown in the below example, so we can't check if those plans are
> constructed correctly, which I'll explain below:

> In HEAD, this test case checks that a Result node is inserted atop of an
> EPQ plan for a foreign join (if necessary) when the foreign join is at
> the topmost join level (see discussion [1]), but the patched version
> doesn't show EPQ plans in EXPLAIN, so we can't check that as-is. Should
> we show EPQ plans in EXPLAIN? My inclination would be to not show them,
> because that information would be completely useless for the user.

In addition to the above reason, it would be waste of cycles to create 
the no-longer-needed EPQ plans to only show them in EXPLAIN, so I kept 
the patch as-is.

> Another thing I noticed is: the previous versions make pointless another
> test case added by commit 4bbf6edfb (and adjusted by commit 99f6a17dd)
> that checks an EPQ plan constructed from multiple merge joins, because
> they changed a query plan for that test case like the above. (Actually,
> though, that test case doesn't need that EPQ plan already since it
> doesn't involve regular tables and it never fires EPQ rechecks.) To
> avoid that, I modified that test case accordingly.

Attached is an updated version of the patchset.  I did that test case 
modification in a separate patch (see the 0002 patch in the attached). 
I also added a bit more assertions and added/tweaked some comments. 
I'll check the patchset once more and add the commit messages in the 
next version.

Best regards,
Etsuro Fujita

Commits

  1. postgres_fdw: Perform the (FINAL, NULL) upperrel operations remotely.

  2. Refactor create_limit_path() to share cost adjustment code with FDWs.

  3. postgres_fdw: Modify regression tests for EPQ-related planning problems.

  4. postgres_fdw: Perform the (ORDERED, NULL) upperrel operations remotely.

  5. Save PathTargets for distinct/ordered relations in root->upper_targets[].

  6. Split create_foreignscan_path() into three functions.

  7. Fix test case for 'outer pathkeys do not match mergeclauses' fix.

  8. postgres_fdw: Avoid 'outer pathkeys do not match mergeclauses' error.