Subject Re: [firebird-support] Large DB after batch import: index rebuild/set stats, backup/restore?
Author Thomas Steinmaurer
>> We're preparing a database for an online system and have imported a
>> large amount of data. The DB file is currently 42 gigabyte. There are
>> two tables with over 110 million records and then some with about 1-2
>> million records. Most other tables only have a few hundred or a few
>> thousand records. No records are deleted.
>
> If you had asked before you did the load, I would have said,
> import with indexes off, then create the indexes.
>> Page size is 4096.
>>
>> Now, after the batch import finishes, I assume the indexes could use
>> with some "conditioning". But what's my best option?
>>
>> 1. Just set statistics on all of them?
>
> Absolutely.

@Kjell: For recalculating the index statistics, add the following SP to
your database.

SET TERM ^^ ;
CREATE PROCEDURE S_RECALCINDEXSTATS returns (
INDEX_NAME VarChar(31),
STATUS VarChar(31))
AS
begin
for select rdb$index_name from rdb$indices into :index_name do
begin
execute statement 'set statistics index ' || index_name || ';';
status = 'Recalculated!';
suspend;
when any do
begin
status = 'Failed!';
suspend;
end
end
end ^^
SET TERM ; ^^


To be executed with:

select * from s_recalcindexstats


HTH.


--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com
My blog:
http://blog.upscene.com/thomas/