Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
There is no easy way imho.
Somehow someone will always be angry.
I usually did it by disallowing the "fuck everything search".
Depending on the internals, a simple COUNT can be way faster than fetching all results.
Hence, as a first step I'd do a reference / begins with (usually begins with is fast, thx to eg Bayer Moore algorithm).
If there is really no match at all, only then the whole search.
Otherwise the partial search with the allow search everything flag (and maybe a hint that <X> additional matches can be found)
@N00bPancakes there is another thing you should do.
If possible, talk with the consumers or at least try to create a statistic about what is searched and why.
There will always be a vale of tears (Change management), but depending on the data you've gathered, the change can be easily justified.
Keep it simple, yet clear.
When eg a search by reference is at ~ 30 %, ~ 70 % of it is full search.
Then only 30 % of 70 % need to be fulfillable by a search with the string begins with logic.
You'd be able to solve 50 % of all searches by a search that I'd expect to be 1-5 % of the usual search time (depending on factors, especially size of data).
I'm mentioning this because most of the times the changes are costly, since searching can be quite complex.
Sadly the nicest graph wins.
Showing that you can reduce the time for an % of X searches down by Y % is often better than explaining why it's wrong and so on....