up vote 2 down vote favorite
share [g+] share [fb]

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? Any suggestions would be appreciated.

link|improve this question

50% accept rate
feedback

1 Answer

up vote 1 down vote accepted

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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