Optimize LIKE '%abc%' queries
Posted by:
Apachez
Date: August 04, 2006 02:12PM
In mysql (and most likely any other sql server software) a query such as LIKE '%abc%' cannot use the index efficient such as a LIKE 'abc%' can do due to the leading % wildcard.
I am thinking of creating an additional column in my table which will have the word in reversed form and create a combined index of (col1, col2_reversed) and then execute the query such as: col1 LIKE 'abc% AND col2_reversed LIKE 'cba%'.
But I guess that wont bring me the same answers as: col1 LIKE '%abc%'. However this will optimize LIKE '%abc' queries by executing them as: col2_reversed LIKE 'cba%'.
Is there perhaps some other optimization I could use in order to boost LIKE '%abc%' queries ?
Subject
Views
Written By
Posted
Optimize LIKE '%abc%' queries
16123
August 04, 2006 02:12PM
7041
August 04, 2006 02:30PM
6458
August 04, 2006 02:36PM
5990
August 04, 2006 02:56PM
7088
August 04, 2006 03:35PM
5570
August 10, 2006 12:41PM
4878
August 10, 2006 01:54PM
5693
August 10, 2006 04:12PM
4211
August 10, 2006 04:27PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.