Good morning!
I wanted to make you aware that there is a patchset that you might find interesting for this topic:https://www.postgresql.org/message-id/36b4f67d-5975-452c-a6b8-b6407f0924ee%40Spark
Regards