Reputation: 3866
Our application provides multiple query interfaces that are basically just text inputs. Is there a best practice on whether the backend logic should be pad the query parameter with wildcards then perform a like or should it just do an equals. Of course another option would be to allow user's to use wildcards and then check and use a "like" if appropriate.
I understand the performance implication of using a wildcard like this and that this could be viewed as a subject question, I just want to know if there is a standard practice.
Upvotes: 4
Views: 316
Reputation: 881103
This is something I would leave up to the user, allowing then to actually make a choice. All the UIs I've seen for allowing user-specified conditions have:
equal to
, not equal to
, less than
, greater than
, starts with
.Then, for the starts with
option, you just tack on %
and use like
.
You'll note (for performance reasons which you seem to already understand) I used starts with
rather than like
to limit the possibility of dragging down the database performance.
I'm not a big fan of unrestricted like
statements although you could also provide ends with
for those DBMS' capable of storing reversed indexes.
Upvotes: 2