Subject Re: [firebird-support] best way to set statistics index on new database
Author Martijn Tonies
Hi Bill,

> I have a user who creates his databases, creates tables, inserts
> initial data, and then wants to set the statistics on the indexes he
> just created. In PostgreSQL, he would issue the VACUUM DATABASE;
> command.
>
> Here is the what he came up with
>
> EXECUTE BLOCK AS
> DECLARE VARIABLE L_INDEX VARCHAR(100); DECLARE VARIABLE L_SQL
> VARCHAR(200); BEGIN
> FOR SELECT RDB$INDEX_NAME FROM RDB$INDICES INTO :L_INDEX DO
> BEGIN
> L_SQL = 'SET statistics INDEX ' || L_INDEX || ';';
> EXECUTE STATEMENT :L_SQL;
> END
> END
>
> This is ok, I guess. I wondered if there was a cleaner way to do this,
> though?

Well, this is how I do it in production databases :-)

I think L_INDEX could be smaller though, or do you have long metadata names?
:-)

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com