Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane escribi�:
>> However, auto_explain is even worse on the other problem. You flat out
>> cannot do catalog lookups in a failed transaction, but there's no way to
>> print a decompiled plan without such lookups. So it won't work. (It
>> would also be appropriate to be suspicious of whether the executor's
>> plan state tree is even fully set up at the time the error is thrown...)
> Maybe it'd work to save the query source text and parameter values
> somewhere and log an explain in a different session.
There wouldn't be a lot of certainty that you got the same plan.
AFAICS the only thing you could do is what Stephen suggested: run
EXPLAIN *before* starting the query. You could stash the text somewhere
and only print it on failure, which would prevent useless log bloat.
But it'd still be awfully expensive.
regards, tom lane