I am trying to understand the query optimization in postgresql and I have a function with some queries in it. Some of them are simple querys that saves a value into a variable and then the next query takes this variable to find something.. lets say:
function()...
select type into t
from tableA
where code = a_c;
select num into n
from tableB
where id = t;
end function...
and many more.. If I want to explain analyse the whole function I execute the command explain analyse select function(); Is this the right way to do it or should I have to explain analyse every query inside the function and if so with what values?
PREPARE thing (arg1, arg2, ...) AS ... original body ...;and call that usingexplain analyze execute thing (args);$1,$2etc variables right? I'm looking for a way to do it for a function with named variables