Subject Recompute all indices within script
Author Adam
Hi Group,

Is it safe to recompute an index through a PSQL 'execute statement'
call? I wish to implement a stored procedure to update all the
statistics. I plan to call it periodically (ie when the software is
upgraded), or on demand if customers are experiencing slow selects to
assist Firebird choosing a sensible PLAN.

eg:

CREATE OR ALTER PROCEDURE SP_CALCSELECTIVITY
AS
DECLARE VARIABLE IDX VARCHAR(50);
DECLARE VARIABLE STMT VARCHAR(75);
BEGIN
FOR
SELECT RDB$INDEX_NAME
FROM RDB$INDICES
INTO :IDX
DO
BEGIN
STMT = 'SET STATISTICS INDEX ' || :IDX;
EXECUTE STATEMENT :STMT;
END
END
^

Thoughts? Comments? Warnings?

Adam