forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbaf17ad
committed
Repair performance regression in information_schema.triggers view.
Commit32ff269 introduced use of rank() into the triggers view tocalculate the spec-mandated action_order column. As written, thisprevents query constraints on the table-name column from being pushedbelow the window aggregate step. That's bad for performance of thistypical usage pattern, since the view now has to be evaluated for alltables not just the one(s) the user wants to see. It's also the causeof some recent buildfarm failures, in which trying to evaluate the viewrows for triggers in process of being dropped resulted in "cache lookupfailed for function NNN" errors. Those rows aren't of interest to thetest script doing the query, but the filter that would eliminate themis being applied too late. None of this happened before the rank()call was there, so it's a regression compared to v10 and before.We can improve matters by changing the rank() call so that instead ofpartitioning by OIDs, it partitions by nspname and relname, castingthose to sql_identifier so that they match the respective view outputcolumns exactly. The planner has enough intelligence to know thatconstraints on partitioning columns are safe to push down, so thiseliminates the performance problem and the regression test failurerisk. We could make the other partitioning columns match view outputsas well, but it'd be more complicated and the performance benefitsare questionable.Side note: as this stands, the planner will push down constraints onevent_object_table and trigger_schema, but not on event_object_schema,because it checks for ressortgroupref matches not expressionequivalence. That might be worth improving someday, but it's notnecessary to fix the immediate concern.Back-patch to v11 where the rank() call was added. Ordinarily we'd notchange information_schema in released branches, but the test failure hasbeen seen in v12 and presumably could happen in v11 as well, so we needto do this to keep the buildfarm happy. The change is harmless so faras users are concerned. Some might wish to apply it to existinginstallations if performance of this type of query is of concern,but those who don't are no worse off.I bumped catversion in HEAD as a pro forma matter (there's nocatalog incompatibility that would really require a re-initdb).Obviously that can't be done in the back branches.Discussion:https://postgr.es/m/5891.1587594470@sss.pgh.pa.us1 parent4cac3a4 commitbaf17ad
File tree
2 files changed
+10
-3
lines changed- src
- backend/catalog
- include/catalog
2 files changed
+10
-3
lines changedLines changed: 9 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2046 | 2046 |
| |
2047 | 2047 |
| |
2048 | 2048 |
| |
2049 |
| - | |
2050 |
| - | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
2051 | 2058 |
| |
2052 | 2059 |
| |
2053 | 2060 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 |
| - | |
| 56 | + | |
57 | 57 |
| |
58 | 58 |
|
0 commit comments
Comments
(0)