Fix O(N^2) stat() calls when recycling WAL segments
Michael Paquier <michael@paquier.xyz>
Fix O(N^2) stat() calls when recycling WAL segments The counter tracking the last segment number recycled was getting initialized when recycling one single segment, while it should be used across a full cycle of segments recycled to prevent useless checks related to entries already recycled. This performance issue has been introduced by b2a5545, and it was first implemented in 61b86142. No backpatch is done per the lack of field complaints. Reported-by: Andres Freund, Thomas Munro Author: Michael Paquier Reviewed-By: Andres Freund Discussion: https://postgr.es/m/20170621211016.eln6cxxp3jrv7m4m@alap3.anarazel.de Discussion: https://postgr.es/m/CA+hUKG+DRiF9z1_MU4fWq+RfJMxP7zjoptfcmuCFPeO4JM2iVg@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xlog.c | modified | +31 −30 |
Discussion
- O(n^2) system calls in RemoveOldXlogFiles() 12 messages · 2021-01-11 → 2021-01-15
- Broken O(n^2) avoidance in wal segment recycling. 8 messages · 2017-06-21 → 2019-05-07