Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 98215D5DA for ; Mon, 8 Oct 2012 23:49:48 +0000 (UTC) Received: (qmail 16846 invoked by uid 500); 8 Oct 2012 23:49:47 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 16817 invoked by uid 500); 8 Oct 2012 23:49:47 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 16809 invoked by uid 99); 8 Oct 2012 23:49:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2012 23:49:47 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jens@couchbase.com designates 206.225.164.32 as permitted sender) Received: from [206.225.164.32] (HELO EXHUB020-5.exch020.serverdata.net) (206.225.164.32) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2012 23:49:41 +0000 Received: from EXVMBX020-1.exch020.serverdata.net ([169.254.4.4]) by EXHUB020-5.exch020.serverdata.net ([206.225.164.32]) with mapi; Mon, 8 Oct 2012 16:49:20 -0700 From: Jens Alfke To: "user@couchdb.apache.org" Date: Mon, 8 Oct 2012 16:49:20 -0700 Subject: Re: Sorting dates in CouchDB Thread-Topic: Sorting dates in CouchDB Thread-Index: Ac2lr4kmVnXTUMytTgi1FnPqjs4ZOg== Message-ID: <2C9DD92C-2612-4441-A2B7-149E9B38008F@couchbase.com> References: <5073232A.9050309@resourceandrevenue.com> <507328E8.4050401@resourceandrevenue.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org On Oct 8, 2012, at 1:14 PM, Mark Hahn 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=92t know how SpiderMonkey does it, but dates are very often represent= ed internally as timestamps*, so the conversion from a number would be very= cheap. Whereas accessing the month/date/etc. would involve first parsing t= he 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=92t know much about this format other than that it=92s binary not ASCI= I. On the other hand, the docs have to be converted to JSON to be sent acro= ss the wire to the view server, and then parsed into JavaScript objects. Th= ere might be tin cans and string involved too. :p =97Jens