I need to explain an application generated SQL statement in PostgreSQL 8.3. I captured the SQL statement in the log but it has a lot of bind variables. Is their any way that I can explain this SQL statement?

When I tried it with the bind variables the parser didn't like it. If I change the bind variables to the actual values used in the statement won't that potentially change the access path to the data?


The plan could actually be different based on the values you provide, so there's no way to do what you want. Just throw in some realistic sample values for your query optimization/tuning.

More details:

The use of bind variables eliminates the parse step for every bound query after the first. This step is not represented in the explain plan. However, the planning and query execution occur after the bind step, which is why your explain plan doesn't work.

Here is the basic flow of building a query in PostgreSQL (at least the last time I used it, which has been a few years):

Receive -> Parse -> Bind -> Plan -> Execute -> Return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.