Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my Firebird database so huge for the amount of data it's holding?

I've been playing around with database programming lately, and I noticed something a little bit alarming.

I took a binary flat file saved in a proprietary, non-compressed format that holds several different types of records, built schemas to represent the same records, and uploaded the data into a Firebird database. The original flat file was about 7 MB. The database is over 70 MB!

I can understand that there's some overhead to describe the tables themselves, and I've got a few minimal indices (mostly PKs) and FKs on various tables, and all that is going to take up some space, but a factor of 10 just seems a little bit ridiculous. Does anyone have any ideas as to what could be bloating up this database so badly, and how I could bring the size down?

like image 859
Mason Wheeler Avatar asked May 11 '11 17:05

Mason Wheeler


People also ask

How good is Firebird database?

Firebird SQL is #4 ranked solution in top Open Source Databases. PeerSpot users give Firebird SQL an average rating of 8.0 out of 10.

What is Firebird database used for?

Firebird is a relational database offering many ANSI SQL standard features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers.


1 Answers

From Firebird FAQ:

Many users wonder why they don't get their disk space back when they delete a lot of records from database.

The reason is that it is an expensive operation, it would require a lot of disk writes and memory - just like doing refragmentation of hard disk partition. The parts of database (pages) that were used by such data are marked as empty and Firebird will reuse them next time it needs to write new data.

If disk space is critical for you, you can get the space back by doing backup and then restore. Since you're doing the backup to restore right away, it's wise to use the "inhibit garbage collection" or "don't use garbage collection" switch (-G in isql), which will make backup go A LOT FASTER. Garbage collection is used to clean up your database, and as it is a maintenance task, it's often done together with backup (as backup has to go throught entire database anyway). However, you're soon going to ditch that database file, and there's no need to clean it up.

like image 152
Noel Avatar answered Sep 17 '22 12:09

Noel