Lately I've been curious about databases so I am reading books and trying to do simple assignments to learn more about them. I read about pages which contain rows and that's all good but how do I serialize those pages back forth to disk.

I Google online and I come accross protobuffs but as far as I know that's an overkill for this. Can I get pointed to right direction, I come across various consideration like endianness for multiplatform serialization format.

Thank you,

3 Replies 3

but how do I serialize those pages back forth to disk.

are you tryng to write a database?

but as far as I know that's an overkill for this

Why do you think so?

Though arguably there is almost notihing to "serialize" for the page. Basically page contains already serialized data for the row (though there can be a lot of details). And probably a header to navigate the storage faster.

For example consider the overall page layout for PostgreSQL (Database Page Layout doc):

Item Description
PageHeaderData 24 bytes long. Contains general information about the page, including free space pointers.
ItemIdData Array of item identifiers pointing to the actual items. Each entry is an (offset,length) pair. 4 bytes per item.
Free space The unallocated space. New item identifiers are allocated from the start of this area, new items from the end.
Items The actual items themselves.
Special space Index access method specific data. Different methods store different data. Empty in ordinary tables.

overall page layout for PostgreSQL

Yes, but how do you deal with a DB that exceeds RAM in that scenario? I am trying to write a simple storage engine. Page has Rows which are kept in some structure which evicts some pages according to an algorithm. (LRU or some other)

@cupofgreentea

AFAIK - basically you don't. You just dump the page to disk.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.