What is the performance of CouchDB stale = update_after?

I am wondering how the stale=update_after function of the CouchDB view API works.

I see here that it returns stale results, and then updates the view:

If set to stale = ok, CouchDB will not refresh the view, even if it is deprecated, the advantage is improved query latency. If set to stale = update_after, CouchDB will update the view after returning an obsolete result. update_after was added in version 1.1.0.

Suppose I inserted a large number of documents โ€” enough to take a few minutes to update the view index โ€” and then I request the view twice in quick succession with stale=update_after . The first request will return very quickly; that the whole point is update_after .

My question is: will the second query also quickly return stale results, or will it wait for the update to complete?

+6
source share
1 answer

The second query also returns stale results. It uses the partial results available at the time of the request to the server. If you just added documents, everything is in order.

But if you change your view, the first query will return the results of the first query and cause a complete rebuild of the view. Thus, the second query is likely to produce no results, or just a few lines.

So, a short answer: in your case, both queries will return quickly, with the second query probably giving the same result as the first, possibly with some extra lines.

Hope I can help!

Yours, Bernhard

+6
source

Source: https://habr.com/ru/post/926073/


All Articles