How does SO store its revisions in the database?
Does it use diffs? If so, what algo does it use?
Meta Stack Exchange is a question and answer site for meta-discussion of the Stack Exchange family of Q&A websites. It only takes a minute to sign up.Sign up to join this community
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:
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