From user-return-22442-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Mon Oct 8 19:27:07 2012 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 22E22D446 for ; Mon, 8 Oct 2012 19:27:07 +0000 (UTC) Received: (qmail 27351 invoked by uid 500); 8 Oct 2012 19:27:05 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 27268 invoked by uid 500); 8 Oct 2012 19:27:05 -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 27259 invoked by uid 99); 8 Oct 2012 19:27:05 -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 19:27:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [62.13.148.143] (HELO outmail148143.authsmtp.com) (62.13.148.143) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2012 19:26:58 +0000 Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt8.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id q98JQZ5h056987 for ; Mon, 8 Oct 2012 20:26:35 +0100 (BST) Received: from [192.168.88.137] ([141.105.156.227]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2) with ESMTP id q98JQUaf090456 for ; Mon, 8 Oct 2012 20:26:31 +0100 (BST) Message-ID: <507328E8.4050401@resourceandrevenue.com> Date: Mon, 08 Oct 2012 21:26:32 +0200 From: Kai Griffin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: Sorting dates in CouchDB References: <5073232A.9050309@resourceandrevenue.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Server-Quench: 10845cfc-117e-11e2-97bb-002264978518 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQsVBFZWRQUV IjkJFyhdUw4oLxtA GxIdIA1HLRwCUgFH L11XNHJYN0AXRV1T HTdLCgcMBUMuGzQ7 awJOElYZfUhOXgd6 UkhDQFRYFwQmABgA GB8eVwdzcgNYenx3 ekRnXHVEXAo7fE4H IysFQ20PZWNlbi4d V0FfOQJUeAdPLUkW d1F+UyYQYGRSZGdp QAU5emhpZ28BdHUK ElxUfUQoTBRDJTkm WxEEEn0jFFEIXG0y KVQNLUMXHGo7WgAA X-Authentic-SMTP: 61633235333037.1014:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 141.105.156.227/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Virus-Checked: Checked by ClamAV on apache.org No, I'm not sure. I can't help but think that at least in view indexing it's less expensive to use numbers than strings... but that's purely instinct and not based on knowledge of how erlang works - perhaps a hold-over from obsolete thinking on my part. I'm often doing date calcs and grouping by years, months, week numbers, or quarters, etc... so 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. On 08/10/2012 21:11, Mark Hahn wrote: >> I'd favour storing them as unix dates > I find it really useful to be able to read the dates in futon and debug > dumps. Are you sure it's a lot slower? > > On Mon, Oct 8, 2012 at 12:02 PM, Kai Griffin wrote: > >> Hi Carl, >> If I were storing dates, then I'd favour storing them as unix dates (which >> are long integers), not strings; not least because it's more efficient, but >> also because you leave the door open to doing something more interesting >> with the dates down the track without having to parse them to/from strings >> first. That said, I think your start key should find the first 2012-10-02 >> successfully, but your end-key would only find up to 2012-12-01T23:59:59 >> (note that's 1 Dec, not 2 Dec), because there is no expiry date exactly >> matching just 2012-12-02. Since your query returned no rows at all, maybe >> the endkey is failing entirely; not sure why that would be. >> Cheers, >> Kai >> >> On 08/10/2012 11:21, Carl Bourne wrote: >> >>> Hi I just wanted to sanity check what I'm doing here. >>> >>> I have a bunch of documents stored in Couch with expiry dates like this: >>> "expire": "2020-07-28T15:13:00+00:00" >>> >>> I have a simple map function defined like this: >>> >>> function(doc) { >>> emit(doc.expire); >>> } >>> >>> I'm then querying the data ranges like this: >>> ?startkey="2012-10-02"&endkey=**"2012-12-02" >>> >>> Is this the correct way to do this type of thing? >>> >>> Regards, >>> >>> Carl >>> >>>