Hi, On 2020-06-29 17:55:28 +0900, Fujii Masao wrote: > One idea to reduce that lock contention is to separate per-query spinlock > into two; one is for planning, and the other is for execution. pgss_store() > determines which lock to use based on the given "kind" argument. > To make this idea work, also every pgss counters like shared_blks_hit > need to be separated into two, i.e., for planning and execution.
I suspect that the best thing would be to just turn the spinlock into an lwlock. Spinlocks deal terribly with contention. I suspect it'd solve the performance issue entirely. And it might even be possible, further down the line, to just use a shared lock, and use atomics for the counters. Greetings, Andres Freund