Subject Using query plan with a dynamic statement
Author patrick_marten
Hello,

I'm using an IB_Cursor to obtain some data for statistics. These data can be viewed in different way (grouped on different fields). Additionally several filter criterias can be applied, depending on what the user would like to do.

I'm checking all this and build my SQL statement. In order to increase performance, I'm using query plan, but sometimes it's causing problems, it seems.

Depending on the final statement, query plan can differ - at least that's what I see in IBXpert or other tools. I'd copied it and added it to the cursor at the end. Mostly it seemed to work with this single plan string for all cases, but recently I'm getting some errors sometimes:
"unsuccessful metadata update
request depth exceeded. (Recursive definition?)"

Once I remove the plan string, everything works fine.

Is it neccessary at all, to add a plan string? That's what I thought because of the performance.

If that's correct: is there a way to determine a correct plan string for each SQL statement (automatically)? There are just too many constellations how the SQL statement could be, depending on the criterias defined by the user...

Best regards,
Patrick