couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yasuhiro ABE <y...@yasundial.org>
Subject Implemented SELECT COUNT(DISTINCT key) SQL query like operation.
Date Wed, 15 Dec 2010 11:18:56 GMT
Hi all,

I implemented the group_numrows operation which calculates the number of reduced group rows.
As an example, a view has four unique keys.

    $ curl 'http://localhost:5984/example/_design/all/_view/all?group=true'
    {"rows":[
    {"key":["bar","35"],"value":3},
    {"key":["foo","25"],"value":3},
    {"key":["somebody","20"],"value":8},
    {"key":["yasu","32"],"value":4}
    ]}

The operation with gorup_numrows=true returns the total number of rows.

    $ curl 'http://localhost:5984/example/_design/all/_view/all?group=true&group_numrows=true'
    {"group_numrows":"4"}

My view has almost 100k unique keys that the reason to implement this operation.
My implementaion is ad-hoc, but if you have huge results set and just needs the total number
and small subset of the results, it might be useful.

More details and the patch is available from my blog;
	http://yasu-2.blogspot.com/2010/12/couchdb-implementation-of-select.html

regards,
-- 
Yasuhiro ABE   <yasu@yasundial.org>  <yadiary@gmail.com>
web:           http://www.yasundial.org/
twitter:       http://twitter.com/YasuhiroABE

Mime
View raw message