3

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?

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
user7286
  • 135
  • 3
  • 7

1 Answers1

2

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

Beep beep
  • 1,833
  • 2
  • 18
  • 33