Hi Boyu, I ran your patch with your reproducer on current master and got the same result you reported. I have about 19 MB of spill without the patch, and 0 with it.
Also, FYI: there is another thread working on the same problem from a different direction: "Lazy snapshot distribution in logical decoding" https://www.postgresql.org/message-id/flat/578D6ABA-FC6B-4E08-955F-3493BA6FACA1%40gmail.com That patch does not skip any snapshots; it waits to hand one out until a transaction actually needs it. Your patch skips the work completely when the commit came from another database. Both change the same code, so the two threads should know about each other. I plan to take a closer look at your patch for Sholok's case this weekend. Thanks, Shihao
