WIP: Sqlite quick search#146
Conversation
This blocks the main thread; we really need to run the main loop both when building and inserting, but otherwise works.
This keeps the UI responsive while we are busy searching. Though perhaps we should show some modal dialog?
|
thanks, worked fine for me. |
|
Appreciate this, when this would be merged? |
|
Hi . Thanks for your work on this issue. I did some tests and, for pattern search (i.e. regex) only on the package names, it seems that a direct search using a for loop and a c++ regex matcher seems to be fast enough and requires minimal implementation:
With the current synchronous populating of the view, doing a full text regex search on the package description too is not responsive enough (for me) though (a tiny bit too slow for immediate update of the view - a second or so). With asynchronous populating of the view it would probably be responsive enough though. In the other hand, if using a database the specialty of full text search, in particular when patterns are used (e.g. regex) need to be taken into consideration (otherwise the performance will most likely be worse than the minimal implementation with a for loop standard c++ regex matcher). For the sqlite case the FTS5 Extension (i.e. "Full-Text Search") is most likely needed. p.s. Here's the base code that I've used on my tests with std::regex (I tried some variations of this, e.g. searching on the descriptions too, etc...): |
|
I've done some tests with a sqlite fts5 database in memory only (there's no point on persisting that data):
On my test implementation the database gets updated at the same point as the view gets updated, so, no more "waiting for index updating to complete". |
|
Mostly the reason for fts is that it can do stemming I believe which produces more meaningful results than substrings |
|
Hi Julian. Nice to hear from you. My tests were mainly to get a rough idea of the times involved, both in the minimal code variant using std::regex and with the database. I think the searching itself can be done synchronously... What were the worst case search times that you got on your tests? I think we could get by with populating the database synchronously too when updating the view after reading the package cache since the 2s additional delay until the view gets updated is not very noticeable. I'll try to run a test asynchronously populating the database in the background after getting a package cache update to get an idea whether the extra complexity pays off. About saving the database to file, I think there's no benefit since it anyway needs to get updated when the app starts. Do you know which search use-cases/patterns would be needed? |
Just filing this now as a replacement for the Xapian search, building the database in-memory for now. This should probably cache in XDG_RUNTIME_DIRECTORY.
TODOs