Hello, I thought about this suggestion again.
Amit's patch suggested in the thread [1] can eliminate SPI plans from INSERT/UPDATE triggers, so our memory pressure issue would be solved. But as far as I can see that thread, Amit's patch doesn't cover DELETE case. It is not a common case, but there is a risk of pressing memory capacity extremely. Considering that, this suggestion might still have good value as Corey said before. I improved a patch according to Peter's following comment : > but I think the > solution of dropping all cached plans as part of DISCARD ALL seems a bit > too extreme of a solution. In the context of connection pooling, > getting a new session with pre-cached plans seems like a good thing, and > this change could potentially have a performance impact without a > practical way to opt out. In a new patch, I separated discarding SPI Plan caches for RI from DISCARD ALL and added a new option "RIPLANS" to DISCARD command to do that. Also a new function, ResetRIPlanCache() which clears SPI plan caches is called by DISCARD ALL or DISCARD RIPLANS. The amount of modification is small and this option can be removed instantly when it is no longer needed, so I think we can use this patch as a provisional solution. Any thoughts? [1] https://www.postgresql.org/message-id/flat/CA%2BHiwqGkfJfYdeq5vHPh6eqPKjSbfpDDY%2Bj-kXYFePQedtSLeg%40mail.gmail.com -- Best regards, Yuzuko Hosoya NTT Open Source Software Center
v2_discard_ri_spi_plans.patch
Description: Binary data