couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lowry, Matthew" <Matthew.Lo...@dsto.defence.gov.au>
Subject RE: Can I get just the keys from a view? [SEC=UNCLASSIFIED]
Date Tue, 15 Jun 2010 04:33:09 GMT
Patrick Barnes stated:
> You say that each of the rows in your view has a large value object,
but that you don't need it? 

No, I didn't say that.

> Then why are you emitting it in the first place?

For the obvious reason ...

> If you have two different use cases;
>   a) Fetching lots of keys
>   b) Fetching the value for a particular key

Exactly.

The client wants to get references to all the values in the view, and
then fetch and present individual values - typically a tiny subset of
the view - as demanded by the user.

> Then the solution may be to have two views - one emitting null
values(a), and the other emitting real values(b). Whether the overhead
of an extra view is worthwhile will depend on your usage patterns.

Sure. But as I stated in my previous reply, I consider this a yucky
work-around rather than a solution.

> Another option might be - if b is not performed often, discard that
view; fetch the document itself and calculate the value client-side when
needed.

This is always an option for any view. Anything computation the server
does in a view is also doable by the client if it has the relevant
documents. But to my mind the whole purpose of a view is that it pushes
the computation to the server side, the server does the computation
once, caches the result, and serves it up to the clients on demand. So
"do the computation client-side instead" seems to defeat the whole
purpose of having views - again not a solution but a work-around.

Reading between the lines, I get the impression that the answer to my
question is "No - the view API does not support fetching keys without
values." This is a pity. And strangely inconsistent with the document
API, in my opinion. The document API allows me to fetch references to
documents without fetching the documents themselves. All the reasons
that motivate the existence of this in the document API are also present
when interacting with views. I can't see any reason why the view API
shouldn't let me fetch references to the values in a view without
fetching the values themselves.

Ho hum and so it goes.

Cheers
 - Matt.

IMPORTANT: This email remains the property of the Department of Defence and is subject to
the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in
error, you are requested to contact the sender and delete the email.


Mime
View raw message