couchdb
couchdb copied to clipboard
Avoid read docs twice when filtered `_changes` is triggered
Overview
- When filered
_changes
is triggered,open_revs()
will read docs. If request parameter hasinclude_docs=true
, thendoc_member()
will also read docs.
Change filter/3
to filter/5
to avoid the above behavior.
- When using filtered
_changes
withstyle=all_docs
,conflicts=true
andinclude_docs=true
, the response should contain the_conflicts
field.
Add open_all_revs_include_doc/2
to include this field.
- Add tests to verify the number of calls to
open_doc/3
.
Testing recommendations
make eunit apps=chttpd suites=chttpd_changes_test
make eunit apps=couch suites=couch_changes_tests
Related Issues or Pull Requests
Checklist
- [ ] Code is written and works correctly
- [x] Changes are covered by tests
- [ ] Any new configurable parameters are documented in
rel/overlay/etc/default.ini
- [ ] Documentation changes were made in the
src/docs
folder - [ ] Documentation changes were backported (separated PR) to affected branches
When filered _changes is triggered, open_rev() will increment stats. If query has include_docs=true, then doc_member() will also increase stats.
In that code path it sounds like the document is being read twice, so incrementing database_reads twice sounds correct. Of course if we could avoid the second read that would be great.
Did I misunderstand the problem?
In that code path it sounds like the document is being read twice, so incrementing database_reads twice sounds correct. Of course if we could avoid the second read that would be great.
I'll try to avoid the second read, thanks for the review.
To reduce the size of the PR, wonder if it would make sense to extract the enhanced tests into a separate PR. We don't intend to change the behavior of _changes
endpoint to tests could be updated first then optimize the doc loading separately.
To reduce the size of the PR, wonder if it would make sense to extract the enhanced tests into a separate PR. We don't intend to change the behavior of
_changes
endpoint to tests could be updated first then optimize the doc loading separately.
Sure, dropped the first commit.
Thanks for the script, @nickva. I'll investigate more.