title: Explain analyze in a loop
body: <p>I want to run an update query about 500k times to calculate the average, highest, lowest time taken to plan and execute the query.</p>
  <p>EXPLAIN ANALYZE seems to works well for this but only if I perform one query update at a time.</p>
  <p>If I do it in a loop, I get following error.</p>
  <blockquote>
  <p>42601 ERROR: query has no destination for result data.</p>
  </blockquote>
  <p>Is there a way to do this in a loop? Or a better way to calculate average, highest, lowest values for planning and execution time for a query?</p>
  <p>Just a loop which keeps changing the status value between 25 and 35</p>
  <pre><code>do $$
      begin
          for r in 1..500000 loop
              if mod(r, 2) &gt; 0 then
                  -- EXPLAIN ANALYZE can't use it here. 
                  UPDATE user SET status=25, WHERE id = '75';
              else
                  UPDATE user SET status=35, WHERE id = '75';
              end if;
          end loop;
      end;
  $$;
  </code></pre>
  <p>Works fine when done over a single query.</p>
  <pre><code>EXPLAIN ANALYZE
  UPDATE user SET status=25, WHERE id = '75';
  </code></pre>