Mr. Tono’s card box: indexes, IDBKeyRange and cursor directions on the real IndexedDB. Every folder the cursor touches is noted; then try a new index without…
Getting everything and filtering in JavaScript feels fast on small data, then slow when there are thousands. An index and an IDBKeyRange let the browser jump straight to the part you want, and a cursor reads one at a time without loading it all. The small rules that catch people: an index is made only when the version goes up, a range’s bounds can be open, and the cursor’s direction decides what happens to repeats.
An index is cards already sorted, a cursor touches them one by one
getAll() then .filter(), or a cursor over the whole store, to get a few rows That reads the whole store for every query. Make an index on the field you search, then index('harga').openCursor(IDBKeyRange.bound(a, b)) so only the range is read.createIndex to an old database, but the index never shows up An index can only be made in onupgradeneeded, and that event only comes when the version in indexedDB.open() is higher than the database’s. Raise the version.IDBKeyRange.bound(a, b) is inclusive on both sides. If the edge rows are missing, look for an unintended bound(a, b, true, true) (open).IDBKeyRange Only what is in the range is touched.advance(4) Four positions skipped in one step.