Reputation: 26387
At the moment I want to have three columns in my database for Notes:
ID | Title | Content
The table could have a few hundred entries.
I want to be able to search for parts of the content. When Content
is "this is a test sentence" and the user searches for "test" or even "te" then the row should be displayed.
Is it okay to store this information in an SQLlite3 database or is there a way to have better performance?
Upvotes: 2
Views: 179
Reputation: 207838
Databases are fine for this stuff, just make sure you use indexes and, if you can avoid usage of LIKE
open on both edges
wrong, it does not use indexes
where data like '%search%'
good, it uses indexes
where data like 'search%'
If you will have records counting over million, or long texts. You could break time in categories, and store them in different tables. This way you will tell the user to search in that category only.
Make sure that you implement the right on text change event + key timer, as you can end up to issue db requests for a search too soon, and the user has not finished typing.
In mobile/desktop environment a 300ms wait for next keypress is advised.
To explain what I mean: suppose you want to searc for "blueray"
you will end up doing inefficient queries, that take long-long time
you should do:
Upvotes: 3
Reputation: 200080
Yes, it's OK to store the information on SQLite3. The SQL will be something like:
SELECT * FROM table_name WHERE Content LIKE '%test%'
Upvotes: 0