diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-11-02 11:31:54 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-11-02 11:31:54 -0400 |
commit | 65c6cab1365ac33b11a49a2a193f6b3f9c53e487 (patch) | |
tree | bcd9f453bd64fb8dc7e893bdc6e39b7d3a9c72c4 /src/backend/parser/parse_func.c | |
parent | d8dba4d03068eeee1ea3ffc8e7c7b4fa3e35a7f4 (diff) | |
download | postgresql-65c6cab1365ac33b11a49a2a193f6b3f9c53e487.tar.gz postgresql-65c6cab1365ac33b11a49a2a193f6b3f9c53e487.zip |
Avoid O(N^2) behavior in SyncPostCheckpoint().
As in commits 6301c3ada and e9d9ba2a4, avoid doing repetitive
list_delete_first() operations, since that would be expensive when
there are many files waiting to be unlinked. This is a slightly
larger change than in those cases. We have to keep the list state
valid for calls to AbsorbSyncRequests(), so it's necessary to invent a
"canceled" field instead of immediately deleting PendingUnlinkEntry
entries. Also, because we might not be able to process all the
entries, we need a new list primitive list_delete_first_n().
list_delete_first_n() is almost list_copy_tail(), but it modifies the
input List instead of making a new copy. I found a couple of existing
uses of the latter that could profitably use the new function. (There
might be more, but the other callers look like they probably shouldn't
overwrite the input List.)
As before, back-patch to v13.
Discussion: https://postgr.es/m/CD2F0E7F-9822-45EC-A411-AE56F14DEA9F@amazon.com
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r-- | src/backend/parser/parse_func.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 3cec8de7da8..542f9167aa1 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -1691,7 +1691,7 @@ func_get_detail(List *funcname, ndelete = list_length(defaults) - best_candidate->ndargs; if (ndelete > 0) - defaults = list_copy_tail(defaults, ndelete); + defaults = list_delete_first_n(defaults, ndelete); *argdefaults = defaults; } } |