Thread: Sending Explain output to a perl client

Sending Explain output to a perl client

From
wsheldah@lexmark.com
Date:

Hi,

I'm trying to tune a query that includes a correlated subquery, by moving the
subquery to a temporary table and joining on that, hoping to improve things by
not executing the subquery for every row. My immediate problem is that since the
temporary table is session specific and I'm running it from perl, I can't paste
the SQL into a psql session to run EXPLAIN on it. Can I treat the EXPLAIN
results like a column from a regular result set and have perl retrieve it like a
regular column value, or is there another way to capture the EXPLAIN output from
a perl client?

Many thanks,

Wes Sheldahl



Re: Sending Explain output to a perl client

From
Tom Lane
Date:
wsheldah@lexmark.com writes:
> or is there another way to capture the EXPLAIN output from
> a perl client?

If you don't want to tweak the DBD driver, you could just read the
explain results in the postmaster's log.

            regards, tom lane

Re: Sending Explain output to a perl client

From
wsheldah@lexmark.com
Date:

Thanks Tom.  Guess I should have tried it before I posted.  Turns out the
explain output goes both in my Apache error log (the script was running under
mod_perl) and my postgresql log, without doing anything special. DBD::Pg must be
treating it like an error message, which seems to work out fine.

At least I learned from finally looking at the pgsql log that I needed to
increase my WAL_FILES parameter. And I figured out which version of the query to
use.  Thanks,

Wes Sheldahl




Tom Lane <tgl%sss.pgh.pa.us@interlock.lexmark.com> on 12/04/2001 01:38:23 PM

To:   "Wesley_Sheldahl/Lex/Lexmark.LEXMARK"@sweeper.lex.lexmark.com
cc:   pgsql-general%postgresql.org@interlock.lexmark.com (bcc: Wesley
      Sheldahl/Lex/Lexmark)
Subject:  Re: [GENERAL] Sending Explain output to a perl client


wsheldah@lexmark.com writes:
> or is there another way to capture the EXPLAIN output from
> a perl client?

If you don't want to tweak the DBD driver, you could just read the
explain results in the postmaster's log.

               regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)