Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIKE predicate

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
US
hi all,
i am running a query which hits a huge table with a billion records and uses a like predicate...here is the query..
select *
from table T
where T.value like '% and %'

i cant ignore the starting % or ending % coz..the value can be anywhere in the string.. like andy...or durand or mandy..so as this particular query is going row by row and scanning the whole database..it is taking hell lot of time..to execute..
IS THERE ANY WAY TO USE SOME ALTERNATIVE FOR "LIKE" PREDICATE..WHICH SPEEDS UP MY QUERY..
thanks in advance..
logic4fun

 
SwampBoogie is probably right. I have to ask though - what kind of table is this that has a billion records? Is every record active and thus needs to be scanned or can you eliminate some based on other criteria? Is the column you're querying an indexed one?
 
Index is not going to help. Any like with a '%' in the front is going to scan the entire table.

Basically what you have here is a bad database design.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top