Measuring SQL execution time in PostgreSQL? MySQL has a performance_schema database that allows one to capture SQL statement execution time data in a table (e.g. performance_schema.events_statements_history_long ; useful MySQL link).

I was wondering if a similar set of tools existed in PostgreSQL?
There isn't a reasonably easy way to do this, but you can:


Log slow queries
Use EXPLAIN ANALYZE to see where the query is actually spending its time.


You could probably store plans in the database somehow but I am not quite sure how this would be done (maybe with a pl/perl function?).  You'd have to roll your own solution though.

Storing plans in the database however is not easy.  One of the huge problems that you will have is getting the recursive structure right so you can query it.  A simple approach might be to take a JSON format and store that, or store XML.