title: Efficient way to simultaneously calc AVG and stddev_pop in postgres
body: <p>stddev_pop() must be calculating AVG() as part of the full calc of standard deviation (unless there's a shortcut I'm unaware of).</p>
  <p>for context, the goal is to test for the difference of means between the these two geom columns.</p>
  <p>Is there any way to access that in order to avoid recalculating AVG()?</p>
  <p>here's an example query:</p>
  <pre><code>select 
      avg(st_length(cons.geom)) as source_avg_length,
      avg(st_length(csn.geom)) as target_avg_length,
      stddev_pop(st_length(cons.geom)) as source_std_length,
      stddev_pop(st_length(csn.geom)) as target_std_length
  from 
      received.conflation_osm_no_service cons,
      received.conflation_stress_network csn ;
  </code></pre>
  <p>and the output of <code>EXPLAIN ANALYZE</code> which makes me think that if I ask for avg() and stddev_pop() it will only do the avg() calc once and reuse it?:</p>
  <p><a href="https://i.stack.imgur.com/4yPuT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4yPuT.png" alt="explain analyze" /></a></p>