Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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