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

Bulk operations #172

Closed
michielbdejong opened this issue Sep 22, 2015 · 0 comments
Closed

Bulk operations #172

michielbdejong opened this issue Sep 22, 2015 · 0 comments
Assignees
Milestone

Comments

@michielbdejong
Copy link
Contributor

  • When data comes in from the server, instead of doing one IDB transaction per change (see https://github.com/Kinto/kinto.js/blob/master/src/adapters/IDB.js#L110), do only one IDB transaction, containing all the updates (e.g. importing 1000 records into an empty database)
  • For Collection#create, Collection#update and Collection#delete, if an Array is passed instead of an object, apply the operation to each element of this array, but in one single IDB transaction.

Background:
This code:

var kinto = new Kinto();
var coll = kinto.collection('foo');
var requests = [];
for (var i=0; i<1000; i++) {
  requests.push(coll.create({ num: i }));
}
var startTime = new Date().getTime();
console.log("Starting");
Promise.all(requests).then(results => {
  console.log("Finished, ms:", new Date().getTime() - startTime)
}, err => console.error(err));

Outputs:

Object { Symbol(record)_3.999wfjax45: Object }
Starting
Finished, ms: 2144

It takes more than 2000 milliseconds on B2G-Desktop on my Macbook to store 1000 items in Kinto.js, so that's a lot, especially if we translate that to low-end devices on which our FxOs Sync app will have to run.

@n1k0 n1k0 added this to the 1.0.0 milestone Sep 30, 2015
@n1k0 n1k0 modified the milestones: 2.0.0, 1.0.0 Oct 22, 2015
n1k0 pushed a commit that referenced this issue Jan 27, 2016
This patch was paired by @leplatrem and @n1k0.

Also fixes #172, fixes #93, refs #16.
@n1k0 n1k0 closed this as completed in 6a49617 Jan 28, 2016
@almet almet removed the in progress label Jan 28, 2016
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

3 participants