PostgreSQL 10 - single big query in UDFs or multiple smaller ones?
0
votes
1
answer
240
views
Many times, I'm able to write a PL/PGSQL UDF in two ways:
1. As a big query usually using WITH clauses and UNION (i.e. more declarative but also more complex to write/read)
2. As multiple smaller queries (i.e. more procedural but also easier to write/read)
I'm aware that PG query planner will plan each smaller query in UDF individually, and I'm afraid that might have an impact on overall performance. What do you guys prefer?
Thank you.
Asked by geeko
(41 rep)
Nov 1, 2017, 06:34 PM
Last activity: Jun 3, 2025, 02:01 PM
Last activity: Jun 3, 2025, 02:01 PM