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-02-15T12:19:30Z
Lists: pgsql-hackers
Attachments
(2019/02/14 18:44), Etsuro Fujita wrote: > (2019/02/12 20:43), Antonin Houska wrote: >> Etsuro Fujita<fujita.etsuro@lab.ntt.co.jp> wrote: >>> Here are my review comments: >>> >>> root->upper_targets[UPPERREL_FINAL] = final_target; >>> + root->upper_targets[UPPERREL_ORDERED] = final_target; >>> root->upper_targets[UPPERREL_WINDOW] = sort_input_target; >>> root->upper_targets[UPPERREL_GROUP_AGG] = grouping_target; >>> >>> I think that's a good idea. I think we'll soon need the PathTarget for >>> UPPERREL_DISTINCT, so how about saving that as well like this? >>> >>> root->upper_targets[UPPERREL_FINAL] = final_target; >>> + root->upper_targets[UPPERREL_ORDERED] = final_target; >>> + root->upper_targets[UPPERREL_DISTINCT] = sort_input_target; >>> root->upper_targets[UPPERREL_WINDOW] = sort_input_target; >>> root->upper_targets[UPPERREL_GROUP_AGG] = grouping_target; >> >> I see nothing wrong about this. > > Cool! > >>> Another is about this: >>> >>> /* >>> + * Set reltarget so that it's consistent with the paths. Also it's more >>> + * convenient for FDW to find the target here. >>> + */ >>> + ordered_rel->reltarget = target; >>> >>> I think this is correct if there are no SRFs in the targetlist, but >>> otherwise >>> I'm not sure this is really correct because the relation's reltarget >>> would not >>> match the target of paths added to the relation after >>> adjust_paths_for_srfs(). >> >> I wouldn't expect problem here. create_grouping_paths() also sets the >> reltarget although adjust_paths_for_srfs() can be alled on grouped_rel >> afterwards. > > Yeah, but as I said in a previous email, I think the root->upper_targets > change would be enough at least currently for FDWs to consider > performing post-UPPERREL_GROUP_AGG steps remotely, as shown in my > patches, so I'm inclined to leave the retarget change for future work. So, here is an updated patch. If there are no objections from you or anyone else, I'll commit the patch as a preliminary one for what's proposed in this thread. 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