Subject Re: [Firebird-Architect] Stored Procedures, Index Statistics and Plans
Author Martijn Tonies
Hello Ian,

> It is my understanding that when stored procedures are compiled
> the execution plan for the sql statements within them are
> calculated.

Not correct. An execution plan is calculated each time the
procedure gets executed (or perhaps more precise, I'm not
entirely sure: when it gets loaded for the first time after there
were no connections to the database).

> When a database is created from script, the tables are typically
> empty when the stored procedures are created. At this time the
> statistics for all the indexes are the same (0).
>
> Does this mean that the optimal plan will never be selected until
> the both the index statistics are recalculated and the stored
> procedures are recompiled?

No, recompilation is not needed and entirely useless.

> If this is the case, is there any way to automatically re-compile
> all procedures (assuming the source exists!) perhaps using EXECUTE
> STATEMENT ...

Nope, unless you have stored the script somewhere :-)

> (This post was influenced by the threads debating the possibility
> of automatically recompiling stored procedures and triggers.)

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com