couchbaselabs/TouchDB-iOS — Issue #7: Storing _id and _rev in 'json' column is redundant
Author: snej
Created: 2011-12-18 18:22:00+00:00
State: open
Labels: performance

The '_id' and '_rev' properties stored in the JSON of the rev.json column are redundant -- the rev ID is stored in the 'revid' column, and the doc ID is in the related 'docs.docid'. Taking them out of the JSON would save a fair amount of space ... something like 60 bytes per revision.

Of course they'd have to be inserted into the JSON returned in the API when fetching the revision. This can be done without having to parse and re-emit the JSON, though: just splice the appropriate JSON fragment into the column value right before the closing "}". E.g. if the value of rev.json is:

{"name":"Bobby","grade":6}

then insert something like this:

,"_id":"TABLES-BOBBY","_rev":"1-357654738567874738"

just before the "}".