added a comment - - edited
and this fix the configuration synchronization time drops down from 70 seconds to 3 seconds. Increasing the prefetch memory buffer from 2MB does not give visible improvements. Moreover, the tests show that when it's too big (~500 MB) it takes too much time to allocate/deallocate the memory which results in worse results than without the fix.
There is still a place for improvement especially in case of larger installations but further improvements require bigger changes which we decided not to do at this moment.
A possible improvement was proposed by sasha: 2 copies of configuration, one that is being updated (writable, locking) another that's being used (read-only, no lock), which are swapped on update.
Another way of improving it - moving the constantly changing columns like "lastvalue", "lastclock" away from configuration (items table), making it reasonable to enable e. g. client-side statement caching.