I am investigating H2 database performance and was curious to why the database file was several megabytes long when only storing hundreds kilos of text, I therefore opened the database file with vim and checked what was inside this binary file.

Unsurprisingly it stored data in a somewhat readable way but what really makes me curious is why between each database row it needs to insert between 30 and 80 rows of:

@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ [...]

I don't know what character it is and its meaning but above all why they need so much seemingly useless repeated data?

Therefore I know why database files are so big but not why they need to be so big and full of "@^" characters.

EDIT: Ok found out those are null values <00><00><00><00><00><00>, so definitely they are useless there. Only answer I gave myself is that H2 someway keeps some free space by putting those zeroes waiting to be filled with data, still would like some answer and how to set how much space to reserve.

  • 1
    It's a binary file. A plain text editor is not going to be able to display the characters that are not ASCII. The database files are not full of "useless" data - it is a binary structured file format. Read the H2 source code if you're interested in the structure of the files. – Philᵀᴹ Feb 21 '14 at 10:14
  • I opened vim in hex editing mode with :setlocal display=uhex, it shows those are actually null values: <00><00><00><00><00> – dendini Feb 21 '14 at 10:38
  • I've not looked at H2 specifically, but most RDMSes allocate space in units (mostly pages/blocks) of uniform sizes (or extents) rather than on a per-row basis as required. Lots of "empty" space is to be expected. – Philᵀᴹ Feb 21 '14 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.