Subject | Re: [firebird-support] How to reduce database size after deleting records?(not by backup/restore) |
---|---|
Author | Ann W. Harrison |
Post date | 2005-02-27T19:09:17Z |
fukura8888 wrote:
it to the operating system. Releasing and reallocating space is
expensive and leads to a database that's fragmented all over the disk.
that you're deleting the records and storing new ones before the deleted
records are garbage collected. In a database that uses multiple record
versions, deleted records can't be removed until all transactions that
could see them have ended. So, the sequence is 1) delete the records,
2) commit the delete, 3) wait for all concurrent transactions to end, 4)
issue a command that will touch the deleted records (e.g. select * from
<table>), then 5) store new records.
If your application must insert new records immediately, you will find
that the database ends up large enough to hold two sets of data, but
eventually the growth will stop as the oldest deleted records are
removed. One way to force the old records to be read is to backup the
database, so that should be a regular part of your system maintenance.
Regards,
Ann
>That's as expected. Firebird reuses space internally but never releases
>
> Hi,
>
> Although I've been deleting quite huge amount of records
> in a firebird database, the size of the database file is
> the same as before.
it to the operating system. Releasing and reallocating space is
expensive and leads to a database that's fragmented all over the disk.
> I added that code in my .net application but the size ofWhen you say "keeps growing", how much does it grow? One possibility is
> the database keep growing although deleted records and
> inserted records are exactly the same.
that you're deleting the records and storing new ones before the deleted
records are garbage collected. In a database that uses multiple record
versions, deleted records can't be removed until all transactions that
could see them have ended. So, the sequence is 1) delete the records,
2) commit the delete, 3) wait for all concurrent transactions to end, 4)
issue a command that will touch the deleted records (e.g. select * from
<table>), then 5) store new records.
If your application must insert new records immediately, you will find
that the database ends up large enough to hold two sets of data, but
eventually the growth will stop as the oldest deleted records are
removed. One way to force the old records to be read is to backup the
database, so that should be a regular part of your system maintenance.
Regards,
Ann