I am using a PL/pgSQL function in PostgreSQL 9.3 with several complex queries inside:
create function f1() returns integer as $$ declare event tablename%ROWTYPE; .... .... begin FOR event IN SELECT * FROM tablename WHERE condition LOOP EXECUTE 'SELECT f2(event.columnname)' INTO dummy_return; END LOOP; ... INSERT INTO ... FROM a LEFT JOIN b ... LEFT JOIN c WHERE ... UPDATE T SET cl1 = M.cl1 FROM M WHERE M.pkcols = T.pkcols; ... end $$ language plpgsql;
If I ran
EXPLAIN ANALYZE f1(), I only get the total time, but no details. Is there a way I can get detailed results for all queries in the function?
If queries in the function should not be optimized by Postgres, I would also ask for an explanation.