Best way to compare the end of a string, use RIGHT, LIKE or other?

亡梦爱人 提交于 2019-12-03 07:16:42

The best way to optimize this for SQL might be to store the REVERSE string value in another column that is indexed and search the left side of that using either LEFT or LIKE.

also, you may use a combination of RIGHT and LENGTH so that you do not hardcode string length.

Parsing strings will have an overhead, best suggestion is the LIKE '%foo' OR as an option. Certain indexes will take advanage and do Seeks over Scans.

You'd have to benchmark to see if suitable but would be easily testable.

Check this out regarding LIKE and INDEX http://myitforum.com/cs2/blogs/jnelson/archive/2007/11/16/108354.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!