Comments (9)
Why are you doing a getAll()
inside of a find()
?
Additionally, there's a small chance that ["catch"]
is invoking some sort of weird behavior in IE's JS parser. Try replacing it with:
$indexedDB.openStore('whiteListNodeIds', function(item) { ... })
.then(null, function(err) { ... });
Finally: What type of data are you storing in the DB? Do your values contain blob
s, or some other sort of large object that might not be optimized in IE?
from angular-indexeddb.
One other thought:
You're performing two queries inside of the same transaction. It's possible that there's a bug in angular-indexedDB that's preventing a digest from being triggered immediately after the first query completes. (I've seen similar odd behavior in my own code; mostly when writing unit tests. It's been noted (#19) that this library handles promises in a fairly unconventional (and potentially problematic) manner.
Try:
var loadWhiteListNodeIds = function () {
$indexedDB.openStore('whiteListNodeIds',
function (table) {
return table.find(7672990).then(function (item) {
$rootScope.$applyAsync(function(){
table.getAll().then(function (whitelistNodeIds) {
console.log('setting whiteListNodeIds');
$scope.whitelistNodeIds = whitelistNodeIds;
});
});
})["catch"](function (error) {
return getAllWhiteListNodesAndAddToDb('whiteListNodeIds');
});
});
};
Note that I've wrapped the getAll()
call inside $rootScope.$applyAsync()
from angular-indexeddb.
it has 200,000 rows containing just a few string columns, lat, long , id. I'll try your suggestion.
I've been debugging this library and because IE doesn't havethis.store.getall'
its's dropping down in to the
this._mapCursor(defer, function (cursor)
code.
from angular-indexeddb.
Ah, #19 is definitely of interest to you.
Every iteration calls defer.notify()
, which in turn calls $rootScope.apply()
. This is going to be ridiculously inefficient for large data sets.
Try commenting out the call to defer.notify()
.
from angular-indexeddb.
Thanks for your swift feedback@schmod
(in the ObjectStore.prototype._mapCursor function)
With defer.notify commented out: loading 200k records took 26,478 seconds.
With it: loading 200k records took 85,583 seconds.
A dramatic improvement, But loading from the server looks like a faster fallback option for IE :(
Also, Your original suggestion of wrapping in $sscope.applyAsync
results in a DOMException
with message TransactionInactiveError
.
from angular-indexeddb.
Are you comfortable enough with the native IndexedDB API to write a variant of your code that doesn't use this library and lives entirely outside of Angular? I'm curious if IE's IndexedDB performance is really that bad.
from angular-indexeddb.
@schmod. I'll attempt that, I'm just going to first run a comparison with this less popular lib https://github.com/gauravgango/gaurav-angular-indexeddb. .I
shall feedback with result.
Update, so that lib (gaurav) takes 46.262 seconds in chrome to load the same dataset and errors with "TypeError: Object doesn't support this action" in IE. So it fared even worse.
Update. So I attempted to use the raw calls instead of any libs
. The timings are Chrome: 36.113s, IE 35.469s.
Code:
var loadWhiteListNodeIds = function () {
var objectStore = db.transaction(storeName, IDBTransaction.READ_ONLY).objectStore(storeName);
$scope.results = [];
$scope.start = new Date().getTime();
objectStore.openCursor().onsuccess = function (event) {
var cursor = event.target.result;
if (cursor) {
$scope.results.push(cursor.value);
cursor.continue();
}
else {
var d = new Date().getTime() - $scope.start;
$scope.whitelistNodeIds = $scope.results;
console.log('time ' + d);
}
};
So at the moment it seems the best approach is to either use this raw call as a fallback for IE, or this lib with the defer commented out....
I'm not sure I like either approach :)
from angular-indexeddb.
Is there a bug here? Can I close this issue? Should something be done?
from angular-indexeddb.
I recommend the removal of defer.notify() to improve the performance of this in IE.
from angular-indexeddb.
Related Issues (20)
- Adds then retrieves first time. Can't retrieve second time HOT 3
- not able to get error log HOT 2
- Upgrade function ordering HOT 1
- logs in code HOT 3
- Wrong usage of @defer.reject() HOT 6
- Unnecessary runtime bower dependency HOT 1
- Is querying over multi entry indexes implemented? HOT 4
- t text to bianry HOT 1
- Unable to install HOT 2
- Additional Maintainers Needed
- Not able to use $indexedDB, $indexedDBProvider in angular service HOT 1
- How can i check if a data sore is exist to insert in it and if isn't create new one?
- i need a function to call it for creating new data store? HOT 1
- How can i get existing data store names...Please? HOT 1
- Unable to store an array of objects corresponding to one key HOT 1
- A) READ THIS BEFORE YOU CREATE AN ISSUE
- Detect failure at the time of opening the store HOT 4
- getAll with limits HOT 2
- Difference between .getAll() and .each()? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-indexeddb.