couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <>
Subject Re: calling views in Erlang
Date Sun, 08 Nov 2009 03:59:32 GMT
On Sat, Nov 7, 2009 at 10:57 PM, Paul Davis <> wrote:
> Norman,
>> I have written some code to query a view within Erlang and it seems
>> too simple :-)
> Welcome to CouchDB. Simple is the implementation corollary of Relax. :)
>> Am I really just looping through a view and returning
>> {ok, State} if a key matches a particular input KeyId and calling
>> {stop, State} when I want the iteration to stop?
>> I appreciate there is an index behind the view which makes things
>> fast, but the looping seems really simple.  Verification of this
>> approach would be very much appreciated as I go forward!
> Even in advanced algorithms indexes are basically just sorted lists at
> the core. Couch's view interface makes that pretty plain. So yes, you
> can just iterate over the views as you see fit. The key to why this is
> quick and delicious is that seeking to the start of iteration (when
> you provide a startkey) is that you only do a log(N) seek to the first
> key.
> HTH,
> Paul Davis

I should mention, that even with no startkey, its still a log(N) seek,
just that its seeking to a special key that sorts before all keys. The
seeking part is important because its assumed that most view
iterations are over small subsets of the index not starting near the
head of the index on average.

Paul Davis

View raw message