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: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>, pgsql-hackers@postgresql.org
Date: 2018-10-05T10:15:41Z
Lists: pgsql-hackers
(2018/08/02 23:41), Tom Lane wrote: > Andrew Gierth<andrew@tao11.riddles.org.uk> writes: >> [ postgres_fdw is not smart about exploiting fast-start plans ] > > Yeah, that's basically not accounted for at all in the current design. > >> One possibility: would it be worth adding an option to EXPLAIN that >> makes it assume cursor_tuple_fraction? > > [ handwaving ahead ] > > I wonder whether it could be done without destroying postgres_fdw's > support for old servers, by instead including a LIMIT in the query sent > for explaining. The trick would be to know what value to put as the > limit, though. It'd be easy to do if we were willing to explain the query > twice (the second time with a limit chosen as a fraction of the rowcount > seen the first time), but man that's an expensive solution. > > Another component of any real fix here would be to issue "SET > cursor_tuple_fraction" before opening the execution cursor, so as to > ensure that we actually get an appropriate plan on the remote side. > > If we could tell whether there's going to be any use in fast-start plans, > it might make sense to build two scan paths for a foreign table, one based > on a full-table scan and one based on EXPLAIN ... LIMIT 1. This still > means two explain requests, which is why I'm not thrilled about doing it > unless there's a high probability of the extra explain being useful. Agreed, but ISTM that to address the original issue, it would be enough to jsut add LIMIT (or ORDER BY LIMIT) pushdown to postgres_fdw based on the upper-planner-pathification work. I'm sorry that I'm really late for the party. Best regards, Etsuro Fujita
Commits
-
postgres_fdw: Perform the (FINAL, NULL) upperrel operations remotely.
- d50d172e517c 12.0 landed
-
Refactor create_limit_path() to share cost adjustment code with FDWs.
- aef65db6769e 12.0 landed
-
postgres_fdw: Modify regression tests for EPQ-related planning problems.
- 0269edefacb7 12.0 landed
-
postgres_fdw: Perform the (ORDERED, NULL) upperrel operations remotely.
- ffab494a4d46 12.0 landed
-
Save PathTargets for distinct/ordered relations in root->upper_targets[].
- 3fdc374b5d24 12.0 landed
-
Split create_foreignscan_path() into three functions.
- 34ea1ab7fd30 12.0 cited
-
Fix test case for 'outer pathkeys do not match mergeclauses' fix.
- 99f6a17dd62a 11.0 cited
-
postgres_fdw: Avoid 'outer pathkeys do not match mergeclauses' error.
- 4bbf6edfbd5d 11.0 cited