<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Is PATINDEX faster than LIKE?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/is-patindex-faster-than-like.aspx</link><description>I keep seeing the same suggestion on various "tips and tricks" websites: For situations in which you might want to use LIKE in the WHERE clause, but for which indexes cannot be used, PATINDEX will perform faster. So, according to these sources , this:</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Is PATINDEX faster than LIKE?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/is-patindex-faster-than-like.aspx#3076</link><pubDate>Wed, 24 Oct 2007 13:24:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3076</guid><dc:creator>Mark Jackson</dc:creator><description>&lt;p&gt;The important bit you missed is the phrase ' but for which indexes cannot be used'. &amp;nbsp;Your test has a clustered index on the searched field and that will be used every time. &amp;nbsp;If you run the same test with a clustered primary key index (on an id field) and your search field set up as a text datatype there is a hugh difference. I have had up to 50% speed gains on a 1.3 million record table of life customer data using patindex, although I would rather shoot myself in the head then do either of these as using a fulltext index on the same data returns the same results in less than a second, compared to 20+ seconds with patindex, or 35+ seconds with like.&lt;/p&gt;
</description></item><item><title>re: Is PATINDEX faster than LIKE?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/is-patindex-faster-than-like.aspx#9483</link><pubDate>Tue, 14 Oct 2008 18:03:03 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:9483</guid><dc:creator>Anon Anon</dc:creator><description>&lt;p&gt;The main reason anyone will swirl away from using SQL FT to using a LIKE or a PATINDEX is when they have to do a *term . &lt;/p&gt;
&lt;p&gt;SQL FT supports only term* and not *term or *term* . &lt;/p&gt;
&lt;p&gt;For example: If I were to search for 123*, I will get 1234, 123456 etc. I can also get 00123 if I were to create a column with the reverse text &amp;amp; create a FT index on it. &lt;/p&gt;
&lt;p&gt;But, How can i find the term with has &amp;quot;0012345&amp;quot; ? Looks like this is not supported with 2008 either ! huh ! After all these years Microsoft does not seem to figure out this trivialities!&lt;/p&gt;
&lt;p&gt;-AA&lt;/p&gt;
</description></item><item><title>re: Is PATINDEX faster than LIKE?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/is-patindex-faster-than-like.aspx#34025</link><pubDate>Wed, 09 Mar 2011 23:13:21 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34025</guid><dc:creator>Alex Cons</dc:creator><description>&lt;p&gt;Why can't they just create a &amp;quot;Reverse&amp;quot; Index? the same way they create an index and check the letters left to right just create another right to left and boom!, you have *123*.&lt;/p&gt;
&lt;p&gt;They must have it for a couple of languages like Arabic or Japanese I would guess.&lt;/p&gt;
</description></item><item><title>re: Is PATINDEX faster than LIKE?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/is-patindex-faster-than-like.aspx#38920</link><pubDate>Fri, 07 Oct 2011 10:47:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38920</guid><dc:creator>Ankit</dc:creator><description>&lt;p&gt;Would some one please answer the poor guys question ?? I wanna know !!&lt;/p&gt;
</description></item><item><title>re: Is PATINDEX faster than LIKE?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/is-patindex-faster-than-like.aspx#38923</link><pubDate>Fri, 07 Oct 2011 14:06:48 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38923</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;About the reverse index? Well they &amp;quot;could&amp;quot; create it (they being the SQL Server team). There are lots of things they could do, but at the end of the day they need to decide what to put in the product based on available time, resources, and the realities of the fact that they're trying to sell software. Would a reverse index improve sales? Probably not much. Therefore, it's not going to be prioritized, no matter how useful it would be.&lt;/p&gt;
&lt;p&gt;But you can create it yourself. Add a computed column using the expression REVERSE(yourTextCol) and index it. And there you have it, a reverse index. Is it the prettiest thing in the world to have floating around in your database? Nope. But it gets the job done.&lt;/p&gt;
</description></item></channel></rss>