Pregunta

I'm evaluating CouchBase for an application, and trying to figure out something about range queries on views. I know I can do a view get for a single key, multiple keys, or a range. Can I do a get for multiple ranges? i.e. I want to retrieve items with view key 0-10, 50-100, 5238-81902. I might simultaneously need 100 different ranges, so having to make 100 requests to the database seems like a lot of overhead.

¿Fue útil?

Solución

As far as I know in couchbase there is no way to implement getting values from multiple ranges with one view. May be there are (or will be implemented in future) some features in Couchbase N1QL, but I didn't work with it.

Answering your question 100 requests will not be a big overhead. Couchbase is quiet fast and it's designed to handle a lot of operations per second. Also, if your view is correctly designed, it will not be "recalculated" on each query.

Also there is another way: 1. Determine minimum and maximum value of your range (it will be 0..81902 according to your example) 2. Query view that will return only document ids and a value that range was based on, without including all docs in result. 3. On client side filter array of results from previous step according to your ranges (0-10, 50-100, 5238-81902) and then use getMulti with document ids that left in array.

I don't know your data structure, so you can try both ways, test them and choose the best one that will fit your demands.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top