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.
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 withoption, you just tack on%and uselike.You’ll note (for performance reasons which you seem to already understand) I used
starts withrather thanliketo limit the possibility of dragging down the database performance.I’m not a big fan of unrestricted
likestatements although you could also provideends withfor those DBMS’ capable of storing reversed indexes.