1

This may be a noob question, sorry! I know that the OS uses caching and other tricks, but let's ignore it for the sake of this question.

I was wondering whether any time I query my liteDB instance does it access the disk? Or is the liteDB instance loaded from disk to memory only once upon initialization, and any subsequent read queries access only the memory (ignoring writes here).

The reason I thought about this question is that I have to search my DB with every click of the mouse. If indeed every query has to access the disk, it might be best to just load my DB into some enumerable once, and any subsequent clicks would access the enumerable instead of the DB.

Also, assuming there is disk access every time, would caching and other OS tricks suffice for me to not avoid this search every click?

Ungoliant
  • 133
  • 2
  • 14
  • Why do you care? Is the reaction too slow? – Fildor Jun 21 '23 at 06:56
  • 1
    It is not too slow, but I was just wondering how it works. – Ungoliant Jun 21 '23 at 07:48
  • 2
    Knowing nothing of liteDB, I would assume it tries to cache things if memory if it can, not doing this would have a massive performance impact. Loading the entire db into memory would fail if there is not enough memory available. If you do queries each click I would assume the mouse position is somehow part of the query, and you might need some type of spatial data structure to make this fast. That *might* be available for your database, but it is probably more common to just create your own in memory structure instead. – JonasH Jun 21 '23 at 07:55
  • Thanks! I have a bunch of rectangles (of varying sizes) and I need to check whether I clicked on one of them. I thought of making invisible buttons but was instructed not to, and to do the search instead. Would you have any recommendations for such a special data structure? – Ungoliant Jun 21 '23 at 10:57

0 Answers0