title: Execute multiple functions together without losing performance
body: <p>I have this process that has to make a series of queries, using pl/pgsql:</p>
  
  <pre><code>--process:
  SELECT function1();
  SELECT function2();
  SELECT function3();
  SELECT function4();
  </code></pre>
  
  <p>To be able to execute everything in one call, I created a process function as such:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION process()
    RETURNS text AS
  $BODY$
  BEGIN
      PERFORM function1();
      PERFORM function2();
      PERFORM function3();
      PERFORM function4();
      RETURN 'process ended';
  END;
  $BODY$
    LANGUAGE plpgsql
  </code></pre>
  
  <p>The problem is, when I sum the time that each function takes by itself, the total is 200 seconds, while the time that the function <code>process()</code> takes is more than one hour!</p>
  
  <p>Maybe it's a memory issue, but I don't know which configuration on <code>postgresql.conf</code> should I change.</p>
  
  <p>The DB is running on PostgreSQL 9.4, in a Debian 8.</p>