4 ms·
>naive q: could one process perform the compilation, store the output in postgresql shmem, then each pg worker copy that code locally ? It would probably be ea
by SigmundA 3y ago
>naive q: could one process perform the compilation, store the output in postgresql shmem, then each pg worker copy that code locally ?
It would probably be easiest to just compile the code to a shared library on disk then it would get memory mapped in all processes using it like any normal shared library, each process must be remapped through whatever binding process to the actual memory addresses.
>can plans be shared ? I might be mistaken but I thought each worker backend can (e.g.) be assigned to a different partition in a partitioned table, with very different table indexes, statistics, etc.
I don't know the details but the PG docs say this about parallel plans, which seems to say each process has its own individual part of the plan:
>Because each worker executes the parallel portion of the plan to completion, it is not possible to simply take an ordinary query plan and run it using multiple workers. Each worker would produce a full copy of the output result set, so the query would not run any faster than normal but would produce incorrect results. Instead, the parallel portion of the plan must be what is known internally to the query optimizer as a partial plan; that is, it must be constructed so that each process that executes the plan will generate only a subset of the output rows in such a way that each required output row is guaranteed to be generated by exactly one of the cooperating processes.
https://www.postgresql.org/docs/current/parallel-plans.html https://www.postgresql.org/docs/current/parallel-plans.html