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

Make use of getAll & getAllKeys when available in IDBObjectStore & IDBIndex #127

Closed
nifgraup opened this issue Aug 27, 2015 · 4 comments
Closed
Labels

Comments

@nifgraup
Copy link

The second edition draft of IndexedDB, https://w3c.github.io/IndexedDB/, defines methods that could speed up some toArray(), limit() & keys() queries. Firefox and Chrome have them implemented behind flags.

@nifgraup nifgraup changed the title Make use of getAll and getAllKeys in IDBObjectStore and IDBIndex Make use of getAll & getAllKeys when available in IDBObjectStore & IDBIndex Aug 27, 2015
@dfahlander
Copy link
Collaborator

Thanks! I've noticed that and will update Dexie in a future version to optimize toArray() and other methods where possible.

Leaving this open until done.

@nifgraup
Copy link
Author

These function are now generally available, the flag is no longer needed.

dfahlander added a commit that referenced this issue May 9, 2016
@dfahlander
Copy link
Collaborator

Fixed in v1.4.0-beta2.

@dfahlander
Copy link
Collaborator

Collection.toArray () is now shortcuted with IDBObjectStore.getAll() or IDBIndex.getAll() depending on whether primary key or index is used. Also works if having used limit() on the collection since getAll () accepts an optional limit.

getAllKeys () on the other hand corresponds to primary keys despite its name but can be utilized by calling the new method Collection.primaryKeys().

On both cases, there are situations when this optimization won't be possible:

  1. If offset() is used on the collection
  2. If filter () or and () is used
  3. If any Dexie algorithm is used such as equalsIgnoreCase () or anyOf ().
  4. If or() is used
  5. If reverse() / desc() is used.

I.e the query must be a simple Key Range query such as between (), above (), below () or equals (). If not, toArray () and primaryKeys () will fallback to a normal cursor based query.

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

No branches or pull requests

2 participants