Subject Re: [firebird-support] can you "compact" a database ?
Author Helen Borrie
>> Silly thought basically since my databases are now moving from sub 100Mb to
>> the 100 to 500Mb range.
>> Is there a means of asking for a single 500Mb of space when restoring a
>> database? So that we have expansion space already allocated.

At 09:47 PM 31/12/2007, Ivan Prenosil wrote:

>FB database file does not hold information about number of pages allocated,
>it is simply derived from the size of file itself.
>So, you can easily expand file size using simple OS API calls.
>On Windows you just need SetFilePointer() and SetEndOfFile().
>(But of course you are doing it on your own risk.)

Indeed. The page inventory won't know about all that "spare" space because it's unallocated. If it thinks it wants more space than its inventory says it has, it requests more. So, instead of having a database file rebuild itself and grow compactly, it will be a big empty balloon accreting a zillion fragments off its perimeter.

Did you know that Fb 2.1 is allocates new pages in batches of a configurable size? As well as giving some "headspace" when approaching a disk full condition, it reduces the amount of disk fragmentation also.

./heLen