jcoglan opened a new issue, #5926:
URL: https://github.com/apache/couchdb/issues/5926
### Version
3.5.1
### Describe the problem you're encountering
Despite the fact that `_changes` does not use indexes to speed up selector
filters, the first time it is requested after creating an index that covers the
filter, it is slower, which possibly indicates it's spending time updating the
index.
### Expected Behaviour
The time taken for `_changes` to respond should not depend on the existence
or otherwise of Mango indexes.
### Steps to Reproduce
To demonstrate this, I created a DB containing a million docs of the form `{
"_id": "doc-N", "value": N }` for N from 1 to 1,000,000. Then I timed how long
it took to run this filtered changes request:
```sh
# uses this shell function:
cdb () {
curl -gsu 'admin:admin' "http://127.0.0.1:5984$1" "${@:2}"
}
time ( cdb '/db/_changes?filter=_selector' -X POST -d '{ "selector": {
"value": { "$lt": 100 } } }' )
```
This would take around 12 seconds.
Then I created an index covering the filtered field and re-timed:
```sh
cdb '/db/_index' -X POST -d '{ "index": { "fields": ["value"] }, "name":
"by-value", "type": "json" }'
time ( cdb '/db/_changes?filter=_selector' -X POST -d '{ "selector": {
"value": { "$lt": 100 } } }' )
```
The first time after creating an index, `_changes` takes over 30s to
complete. On later requests it's back to around 12s, possibly very slightly
slower.
### Your Environment
macOS 15, CouchDB 3.5.1, single node, database created with q=2, n=1
### Additional Context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]