Slow Query Performance in PouchDB with Synced CouchDB Index
- Dominant language
- JavaScript
- Stars
- 17.6k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I am experiencing slow query performance in PouchDB despite using an index synced from CouchDB. Below are the details of my setup and the issue:
### setup
### This is my index in CouchDB
{
"_id": "_design/employee-index",
"_rev": "9-853ffb68171b1e78206646d0a63c22bc",
"language": "query",
"views": {
"residents-index": {
"map": {
"fields": {
"firstName": "asc",
"projectId": "asc"
},
"partial_filter_selector": {}
},
"reduce": "_count",
"options": {
"def": {
"fields": [
"firstName",
"projectId"
]
}
}
}
}
}
### PouchDB sync
I have synced the above index from CouchDB to PouchDB.
The index appears in IndexedDB as _pouch_employee_mrview_. It has records.
### Query
db.find({
selector: {
projectId: 'specificProjectId',
firstName: { $gte: null }
},
use_index: '_design/employee-index'
}).then(function (result) {
console.log(result.docs);
}).catch(function (err) {
console.error(err);
});
### Issue
Despite using the use_index field in my query, the performance is still slow
### Info
- Environment: browser (using pouchdb-browser)
- Platform: (Chrome/FF/Safari/Edge/iOS/Android/etc.)
- Adapter: indexeddb
- Server: CouchDB
### My questions
1. Since I have created the Index at CouchDB and synced with PouchDB, Is it not using the Index properly?
2. Do I need to recreate the index using createIndex() from Pouch side? I queried the PouchDB index using getIndexes(). The index is available.
3. If I edit any field on PouchDB, Will that warm up the Index automatically.
Hi @maintainer, I would greatly appreciate it if you could take a look at this issue at your earliest convenience. The slow query performance is significantly impacting our application’s performance, and any guidance or suggestions would be immensely helpful. Thank you!
Contributor guide
Assessment
This issue has not been assessed yet.