title: How can profiling agg in Postgresql?
body: <p>I created a SQL function and put it at GROUP BY , HAVING clause, but I found the agg function takes too much time. the query plan is here </p>
  
  <p><a href="http://explain.depesz.com/s/ooaM" rel="nofollow">http://explain.depesz.com/s/ooaM</a> </p>
  
  <p>The functions should not be so slow, I want to understand why it takes so long. Could anyone suggest some tools I can use to profile postgresql? I'm working on pg9.4 and as I'm working on its source code, I would like to understand its internal. Thanks.  </p>