Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find action, slow performance #118

Open
schmm2 opened this issue Sep 22, 2019 · 2 comments
Open

find action, slow performance #118

schmm2 opened this issue Sep 22, 2019 · 2 comments

Comments

@schmm2
Copy link

schmm2 commented Sep 22, 2019

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.

@schmm2
Copy link
Author

schmm2 commented Sep 29, 2019

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
Copy link
Collaborator

jlami commented Mar 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants