Dexie.js: Slow get operation in rare situations

This is probably too vague but I wanted to ask about it.

I just had the situation again (I’ve had it once before some time ago) where very simple calls on a very small database were taking much longer than normal.

This is the query:

db.items.where('location').equalsIgnoreCase(myLocation).first()

This is on a collection of only 10 simple items, nothing crazy large in there and no indexes on binary data.

Normally this query takes about ~2ms or less but suddenly it took around ~450ms. I couldn’t figure out why at all, even subsequent queries were that slow. This is in Electron, restarting didn’t help either. I ended up deleting the indexeddb database just to see if that was the problem and now the queries are fast again.

Any idea what this could be or what I could test next time I see this? My worry is that this could happen to end users.

About this issue

Most upvoted comments

Happening again with the extra await. This is the full function now:

  static async getByPath(p: string): Promise<Track | undefined> {
    p = fixVolume(fixPath(p)).normalize()

    return await db.tracks.where(TrackFieldsInternal.LocationNormalized).equalsIgnoreCase(p).first()
  }

I’ll try the transpile thing next.

I’ll try a reboot next time I see this problem, that should rule that out. Will report back as soon as it happens again 👍 Thanks for thinking with me!