incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Alfke <j...@couchbase.com>
Subject Re: Sorting dates in CouchDB
Date Mon, 08 Oct 2012 23:49:20 GMT

On Oct 8, 2012, at 1:14 PM, Mark Hahn <mark@hahnca.com> wrote:

> I've always just felt more comfortable having them stored as dates to
> begin with so there's no additional conversion process to extract those
> year, month, etc values.
> For that matter it might be slower to
> convert from the JSON number in a string to a Date than from a string to a
> Date.  I have no idea of course.

I don’t know how SpiderMonkey does it, but dates are very often represented internally as
timestamps*, so the conversion from a number would be very cheap. Whereas accessing the month/date/etc.
would involve first parsing the date string to a numeric timestamp, then processing that timestamp
to re-derive those fields.

> I wonder if Couch stores the JSON as a
> string in the DB or converted to binary.

I believe CouchDB stores documents internally as serialized Erlang terms. I don’t know much
about this format other than that it’s binary not ASCII. On the other hand, the docs have
to be converted to JSON to be sent across the wire to the view server, and then parsed into
JavaScript objects. There might be tin cans and string involved too. :p

—Jens


Mime
View raw message