I have written a custom PostgreSQL client and I want to add a function that would automatically capture query execution time.
The current executionTime
value in Slonik results records the total query execution time, including the roundtrip and parsing. In order to capture the actual query execution time, I plan to prefix every query with EXPLAIN ANALYZE
, parse the explanation and capture the results of the query. However, I cannot find a way to run EXPLAIN ANALYZE and capture the actual query result (in addition to explain output).
How to run EXPLAIN ANALYZE and get results of the query?
analyze
or get the results.auto_explain
and capture the notice during the execution. I am looking for a solution that ideally does not require to configure the database instance outside of the query/ procedure.auto_explain
also runs the query separately from theexplain
stepauto_explain
solves.