Subject | best way to set statistics index on new database |
---|---|
Author | Bill Oliver |
Post date | 2007-08-22T14:54:29Z |
Hello all!
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?
-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?
-bill