pouchdb-community/relational-pouch

find action, slow performance

Opened this issue · 2 comments

Hello there

I have 200 documents in a remote CouchDB synced down to a local pouchDB with indexDB. 10 of them are of type "articleCategory". If I run this query:

this.db.rel.find('articleCategory',['1','2'....]);

The time it takes to finish is approx 15seconds according to measurements I have done with console.time. I am still a beginner with pouchdb... but I think this should run much faster. Is there something I can check what could be wrong with my code...or the db itself?

I understand that in pouchDB we can work with indexes...but I guess even without an Index it should be faster than 15sec.

Im using the newest version of pouchDB and relational-pouch.

Thanks in advance for any help.

Example i query all docs with data.type == 'supplier'.

When I change to plain db.find its still pretty slow. more or less 3s.
When I query with db.rel.find (and remove all relationship entries) I get 300ms, which is awesome.
So not the device and not the app construct slows things down.

No idea were I'm doing something wrong. Please advice. If you need more infos or logs I'm happy to provide them.

jlami commented

I think this is due to the fact that relational-pouch does not create indexes.
db.rel.find without any relationships does not use db.find, only alldocs. So only when you use db.find or relations will indexes be needed to speed things up.
We could let relational-pouch create the indexes that are needed to speed things up, but for now we let the application decide which indexes it wants. See here for an example: https://github.com/pouchdb-community/ember-pouch/blob/086feb41e5e193b69d7da35e6b73a8e55b71b05c/addon/adapters/pouch.js#L219