Would using doc.order_items[i].item_id rather than .title speed things up at all? I would imagine that your index would be smaller since there wasn't a (potentially large) string to read/write, and the numeric comparison should be faster than the string comparison when sorting the output (but that's all just me guessing).
As Paul said, pre-summing duplicate items in the order prior to emit(rest_id, item, count) might also help. Eli On Wed, Oct 6, 2010 at 7:10 PM, Nick Poulden <[email protected]> wrote: > Hi, > > Is it possible to *only* store the reduce value of a view? > > I'm storing a large database of orders for my online takeaway ordering > website and collating stats, specifically the number of times a particular > dish has been ordered. The view looks something like this: > > // Map > function(doc) { > if(doc.restaurant_id && doc.order_items) { > for(var i=0; i< doc.order_items.length; i++) { > emit([doc.restaurant_id, doc.order_items[i].title], 1) > } > } > } > > // Reduce > function(keys, values, rereduce) { > return sum(values); > } > > The problem is that there are tons of documents in the view index that > aren't much use and view indexing is taking about 10 times longer since I > added this function. The only thing I want to store is the reduce value. Is > that possible, or is it a feature that may be added at some point in the > future? > > Thanks, > > Nick Poulden > http://www.e-resistible.co.uk >
