This depends heavily on the length of the needle (query) versus the length
of the haystack (database); and if you'll be doing repeated searches that might
make it worth doing pre-processing of either one. You can read the wikipedia page
for the Rabin–Karp string matching algorithm to get a sense of the issues involved.
Things like the expected versus worst-cases big-O times might be important, depending on
your use case, and there are various classical algorithms available that improve
on brute force in various circumstances.
If you want deeper discussion, then CLR[1] and/or Dan Gusfield's book "Algorithms on Strings, Trees, and
Sequences" might be good reading.
That said, brute force search is often just fine as it tends to have a high L1-cache hit rate.