If you know erlang I would advise you to extend _stats, it would give you the best performance. http://wiki.apache.org/couchdb/Runtime_Statistics
There is also some work in doing visualization to it: https://github.com/mcaprari/couchdb-stats If you want to go the javascript route I would advice you to use update as a incremental counter, you would supply the _id and it would increment the page count. You can do more fancy stuff if you want. Your would have a separate document for the counters, possible with a _id scheme like this: current_id+_stats" So the stat document for 879759be9418a39aab624e9619092c80 would be 879759be9418a39aab624e9619092c80_stats. Then you would use views to collect the data with the key as the id of the original document. If you use a single count document it can balloon very fast also slow down everything because on update it has to send a new document, and the couchdb database file would grow really fast and you would have to compact very often. Regards, Olafur Arason On Tue, May 10, 2011 at 09:05, He Shiming <heshim...@gmail.com> wrote: > Hi, > > I'm working on this project, that needs to count page views. I came up > with two possible solutions: > > 1. For each page to be counted, use a single count document, and an > update handler to count on each page view > 2. Create a new document on each page view, this way I get to record a > history of views, which I prefer > > I was wondering if the second method will consume too much space and > CPU on a heavy traffic website. If I need the log of page views, it > looks like this is the only way. But is it the correct and optimal way > of doing counters? > > Or should I pick an alternative database for counters? > > -- > Best regards, > He Shiming >