Re: executor relation handling
Tom Lane <tgl@sss.pgh.pa.us>
Attachments
- 0001-use-array-not-list-of-ExecRowMarks.patch (text/x-diff) patch 0001
- 0002-postpone-rowmark-relation-access.patch (text/x-diff) patch 0002
I wrote: > Still need to think a bit more about whether we want 0005 in > anything like its current form. So I poked at that for a bit, and soon realized that the *main* problem there is that ExecFindRowMark() eats O(N^2) time due to repeated searches of the es_rowMarks list. While the patch as stated would improve that for cases where most of the partitions can be pruned at plan time, it does nothing much for cases where they can't. However, it's pretty trivial to fix that: let's just use an array not a list. Patch 0001 attached does that. A further improvement we could consider is to avoid opening the relcache entries for pruned-away relations. I could not find a way to do that that was less invasive than removing ExecRowMark.relation and requiring callers to call a new function to get the relation if they need it. Patch 0002 attached is a delta on top of 0001 that does that. Replicating your select-lt-for-share test case as best I can (you never actually specified it carefully), I find that the TPS rate on my workstation goes from about 250 tps with HEAD to 920 tps with patch 0001 or 1130 tps with patch 0002. This compares to about 1600 tps for the non-FOR-SHARE version of the query. However, we should keep in mind that without partitioning overhead (ie "select * from lt_999 where b = 999 for share"), the TPS rate is over 25800 tps. Most of the overhead in the partitioned case seems to be from acquiring locks on rangetable entries that we won't ever use, and none of these patch variants are touching that problem. So ISTM that the *real* win for this scenario is going to come from teaching the system to prune unwanted relations from the query altogether, not just from the PlanRowMark list. Keeping that comparison in mind, I'm inclined to think that 0001 is the best thing to do for now. The incremental win from 0002 is not big enough to justify the API break it creates, while your 0005 is not really attacking the problem the right way. regards, tom lane
Commits
-
Avoid O(N^2) cost in ExecFindRowMark().
- f9eb7c14b08d 12.0 landed
-
Remove some unnecessary fields from Plan trees.
- 52ed730d511b 12.0 landed
-
Restore sane locking behavior during parallel query.
- 29ef2b310da9 12.0 landed
-
Remove more redundant relation locking during executor startup.
- f2343653f5b2 12.0 landed
-
In the executor, use an array of pointers to access the rangetable.
- d73f4c74dd34 12.0 landed
-
Centralize executor's opening/closing of Relations for rangetable entries.
- 9ddef36278a9 12.0 landed
-
Change executor to just Assert that table locks were already obtained.
- 9a3cebeaa7fd 12.0 landed
-
Change rewriter/planner/executor/plancache to depend on RTE rellockmode.
- 6e35939febf8 12.0 landed
-
Add assertions that we hold some relevant lock during relation open.
- b04aeb0a053e 12.0 landed
-
Create an RTE field to record the query's lock mode for each relation.
- fdba460a26af 12.0 landed