Subject Re: [firebird-support] Allocate file on winchester
Author Ivan Prenosil
> From: "Szak�ly Bal�zs" <szakalyb@...>
> Is any trick or procedure to create a larger fdb file on winchester when i create the database, or after the create?
> Because when the file grow daily ~1MB with 10K step, then the winchester will be wery fragmented..., but if i can set the size to
> 1GB on create, then the file remain unfragmented...


Either create temporary table, insert lot of rows, then roll back. (see example below)

Or use SetEndOfFile() API function (very fast; not officially supported,
but seems to work o.k.).

Ivan Prenosil
http://www.volny.cz/iprenosil/interbase


CREATE TABLE tmp_space (
x CHAR(10000) CHARACTER SET ascii );

/* The input parameter represents number of MB the database should by inflated by */
CREATE PROCEDURE allocate_disc_space (i INTEGER) AS
DECLARE VARIABLE s100 VARCHAR(100) CHARACTER SET ascii;
DECLARE VARIABLE s1000 VARCHAR(1000) CHARACTER SET ascii;
DECLARE VARIABLE s10000 VARCHAR(10000) CHARACTER SET ascii;
BEGIN
IF (i>0)

THEN
BEGIN
s100='1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij';
s1000=s100||s100||s100||s100||s100||s100||s100||s100||s100||s100;
s10000=s1000||s1000||s1000||s1000||s1000||s1000||s1000||s1000||s1000||s1000;
/* input parameter represents MB */
i=i*100;

WHILE (i>0) DO BEGIN
INSERT INTO tmp_space VALUES (:s10000);
i=i-1;
END
END

ELSE
BEGIN
DELETE FROM tmp_space;
END
END