Discussion:
Is there a way to get both the plan and the results?
François Beausoleil
2014-10-01 17:46:30 UTC
Permalink
Hi all!

Building a small tool, and it would be super useful if I could get both the query results and the plan at the same time. At the moment, the tool accepts a SQL query, drops it into a file and call psql --file=whatever.sql. I can change to use a lower-level API if necessary.

Ideally, I’d like to do something like EXLAIN (ANALYZE, RESULTS) SELECT ...

I’m talking about multi-minute queries, so it’s less than ideal if I have to run the query twice: once for EXPLAIN ANALYZE, once for the actual results.

Looking around, https://duckduckgo.com/?q=postgresql+get+query+results+and+query+plan+in+single+call doesn’t return anything useful. Google neither, for that matter. The PG mailing list archives seem to not have any results on that.

I’m specifically using 9.1. Not opposed to upgrade if necessary.

Thanks!
François Beausoleil
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
David G Johnston
2014-10-01 18:40:18 UTC
Permalink
Post by François Beausoleil
Hi all!
Building a small tool, and it would be super useful if I could get both
the query results and the plan at the same time. At the moment, the tool
accepts a SQL query, drops it into a file and call psql
--file=whatever.sql. I can change to use a lower-level API if necessary.
Ideally, I’d like to do something like EXLAIN (ANALYZE, RESULTS) SELECT ...
I’m talking about multi-minute queries, so it’s less than ideal if I have
to run the query twice: once for EXPLAIN ANALYZE, once for the actual
results.
Looking around,
https://duckduckgo.com/?q=postgresql+get+query+results+and+query+plan+in+single+call
doesn’t return anything useful. Google neither, for that matter. The PG
mailing list archives seem to not have any results on that.
I’m specifically using 9.1. Not opposed to upgrade if necessary.
See:

http://www.postgresql.org/docs/9.1/static/auto-explain.html

There is no way to do so from a client interface.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/Is-there-a-way-to-get-both-the-plan-and-the-results-tp5821313p5821315.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Continue reading on narkive:
Loading...