How does SO store its revisions in the database?

Does it use diffs? If so, what algo does it use?


1 Answer 1


No, it does not store diffs. The complete source of each version is simply kept for each revision.

Although the exact implementation might differ we can peek at the database schema for SEDE and the Data Dump that roughly matches the production database. In there we find the PostHistory table which hold the initial revision for a post with typeid's 1,2 and 3 (body, title, tags respectively) and any subsequent revisions for typeid's 4,5 and 6.

Looking at the rows for a single post, for example Adding a list of objects to a dictionary you'll find this:

enter image description here Click the image for the SEDE query

In the text column you'll find the exact content as submitted, aka the markdown, much similar as when you go through the revisions and then click on the source for a specif revision.

If you want to know if both body, tags and titles were edited in a single revision, pay note to the revisionGuid column. Records with same Guid denote a single revision.

What you see on a page when you're offered a diff view of two revisions is generated on the fly by a proprietary C# implementation as explained here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .