You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Rory Franklin <ro...@chillibean.tv> on 2012/07/11 12:31:27 UTC

Large key's in views

We have a tree structure stored in Couch to mimic a filesystem, and I am trying to determine the most efficient way to calculate storage amounts for any node (and below).

As each leaf contains its path up to the root node, would it be bad form to emit out the path with a value of the sum of the contained files within that node, considering that node depth could be huge? (although in reality would rarely go more than 20 levels deep, more often would be less than 10 levels)

So it could look like this:

emit(["6a1b6034bc634e3cf6865da4780c39eb", "d70c3dc615aaa3065e2edd4ecd9af74b", "6a1b6034bc634e3cf6865da4780c50ad" …], 50030203)

From there I can do a startkey/endkey query to get all nodes below a certain point and do a reduce to get the total file size.

My worry is that they emitted key being very large could be problematic, but I guess this would only impact on how much storage the view will use on disk?




Rory

Re: Large key's in views

Posted by Simon Metson <si...@cloudant.com>.
Hi Rory,  
I can't see why that would be a problem, I've certainly had views with 5-10 elements in the key. I think you'd need to measure it to be sure though.  
Cheers
Simon


On Wednesday, 11 July 2012 at 11:31, Rory Franklin wrote:

> We have a tree structure stored in Couch to mimic a filesystem, and I am trying to determine the most efficient way to calculate storage amounts for any node (and below).
>  
> As each leaf contains its path up to the root node, would it be bad form to emit out the path with a value of the sum of the contained files within that node, considering that node depth could be huge? (although in reality would rarely go more than 20 levels deep, more often would be less than 10 levels)
>  
> So it could look like this:
>  
> emit(["6a1b6034bc634e3cf6865da4780c39eb", "d70c3dc615aaa3065e2edd4ecd9af74b", "6a1b6034bc634e3cf6865da4780c50ad" …], 50030203)
>  
> From there I can do a startkey/endkey query to get all nodes below a certain point and do a reduce to get the total file size.
>  
> My worry is that they emitted key being very large could be problematic, but I guess this would only impact on how much storage the view will use on disk?
>  
>  
>  
>  
> Rory