diff options
author | Alex Anderson <anderson@medicmobile.org> | 2017-05-25 21:26:05 +0000 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2017-06-06 12:17:53 -0400 |
commit | 42b34010841afe00596c579af346651b7202d963 (patch) | |
tree | 1ddd0d54f393b57584d811374b10d6226654941f | |
parent | 35cefa4fa1fe90342d262728648b732c388d7171 (diff) | |
download | couchdb-42b34010841afe00596c579af346651b7202d963.tar.gz |
Allow configuration of max doc IDs for optimised code path in changes filter
There are two implementations for filtering the _changes feed by doc_ids. One
implementation is faster, but requires more server resources. The other is
cheaper but very slow. This commit allows configuration of the threshold at
which couch changes to using the slower implementation using:
[couchdb]
changes_doc_ids_optimization_threshold = 100
COUCHDB-3425
-rw-r--r-- | rel/overlay/etc/default.ini | 4 | ||||
-rw-r--r-- | src/couch/src/couch_changes.erl | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini index 5dc462827..b92b1b7c1 100644 --- a/rel/overlay/etc/default.ini +++ b/rel/overlay/etc/default.ini @@ -35,6 +35,10 @@ default_security = admin_local ; stem_interactive_updates = true ; update_lru_on_read = true ; uri_file = +; The speed of processing the _changes feed with doc_ids filter can be +; influenced directly with this setting - increase for faster processing at the +; expense of more memory usage. +changes_doc_ids_optimization_threshold = 100 [cluster] q=8 diff --git a/src/couch/src/couch_changes.erl b/src/couch/src/couch_changes.erl index 52ff39ded..835251d50 100644 --- a/src/couch/src/couch_changes.erl +++ b/src/couch/src/couch_changes.erl @@ -29,10 +29,6 @@ -export([changes_enumerator/2]). -% For the builtin filter _docs_ids, this is the maximum number -% of documents for which we trigger the optimized code path. --define(MAX_DOC_IDS, 100). - -record(changes_acc, { db, view_name, @@ -556,9 +552,14 @@ send_changes(Acc, Dir, FirstRound) -> end. -can_optimize(true, {doc_ids, _Style, DocIds}) - when length(DocIds) =< ?MAX_DOC_IDS -> - {true, fun send_changes_doc_ids/6}; +can_optimize(true, {doc_ids, _Style, DocIds}) -> + MaxDocIds = config:get_integer("couchdb", + "changes_doc_ids_optimization_threshold", 100), + if length(DocIds) =< MaxDocIds -> + {true, fun send_changes_doc_ids/6}; + true -> + false + end; can_optimize(true, {design_docs, _Style}) -> {true, fun send_changes_design_docs/6}; can_optimize(_, _) -> |