Hi, Currently when we create a PreparedTransaction, we call ProcArrayAdd. Then when we FinishPreparedTransaction, we canl ProcArrayRemove. Both functions need do lots of memmove when holding a LW_EXCLUSIVE lock on ProcArrayLock. I guess this would be a common bottleneck on a PostgreSQL-based distributed database.
Should we do something to improve this? The direct idea in my mind is we can cache N PGPROCs for prepared xact in ProcArray, it should be the number of concurrently *active* preapred transaction which maybe much less than max_prepared_xacts value, so it probably not too bad for ProcArray Scan. Then we can remove the both ProcArrayAdd and ProcArrayRemove. However besides we have to manage the PGPROC state carefully for these cached PGPROCs, another troubles is the PGPROC is bind to database and user, this make them hard to manage, any idea how to handle this? I want to PoC the above idea, but I hope some difference voice or the suggestion about the database/user stuff. -- Best Regards Andy Fan
