Forum OpenACS Q&A: obtaining the output from PostgreSQL EXPLAIN


I'm writing a very simple web interface to a PostgreSQL database using
Aolserver and the OpenACS pgdriver, and I am wondering whether it's
possible to obtain the output of the PostgreSQL EXPLAIN command in my
Tcl scripts?  The output does appear in the Aolserver log file, so, in
a worst case scenario, I could retrieve the output from the log file,
but that is not a very elegant solution.

The reason I'd like the output from the EXPLAIN command is to be able
to estimate the time required for a submitted query and to protect the
server from an innocent user doing a "select *" from a several GB
database.  If someone out there has a better idea for how to do this,
I'd love to hear about it.


Todd Small

Posted by David Walker on
Another inelegant solution might be to exec plsql -c "explain select
* from several_gb_database" and read the query plan that way.