8
votes

I had expected that using SQLite would reduce the the total size of the data used, but actually I am seeing a CSV representation being 4mb smaller than the SQLite database.

The database contains a single table with 400,000 rows. The table has four columns.

The CSV file comes to 19MB and the SQLite database comes to 23MB. If this table was 10 times larger I would be better off parsing the CSV file rather than SQLite.

Why is the SQLite database larger than the CSV file?

3

3 Answers

10
votes

There should be no expectation of the SQLite database file being smaller. The purpose of putting data in a database/table is to access that data according to business rules/SQL joins that are required. Indexes and other metadata like table definitions can easily explain the additional space requirements.

0
votes

A sqlite db contains, reserved space for header, also contains table schemas and extra information like App Id, version, encoding see link for more information below:

http://www.sqlite.org/fileformat.html

0
votes

Look at The SQLite Database File Format

you will see where the overhead comes from.

The purpose of a database is not only storing raw data. You get the whole relational structure, indexes... The only thing you might have expected is to have the datafile compressed but it would have probably hit performance.