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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex view query needs improving - CHARINDEX join

Status
Not open for further replies.

eo

MIS
Apr 3, 2003
809
I have a few tables which are used in a view (SQL 2012), but the query takes far too long to run and I am looking at suggestions
to improve performance. I do howevver know that clear bottleneck is the following join..

Code:
  LEFT JOIN dbo.ToneDictionary D
  ON CHARINDEX(Dictionary,Title) > 0

The reason for such a join is because I have to establish if the [Title] contains one or more (or none) of the words in [Dictionary]. There could be millions of [Title]'s and about 20 or so [Dictionary] values.

I know this is a very broad question, but has anyone achieved something similar by using something other than a CHARINDEX join?



EO
Hertfordshire, England
 
YOu have not joined the tables, there must be a relationship, your Charindex is a condition

Syntax should look like

LEFT JOIN dbo.ToneDictionary D
ON Table.Field1 = D.Field2
and CHARINDEX(Dictionary,Title) > 0

Ian
 
try these - it may be faster
Code:
LEFT JOIN dbo.ToneDictionary D
  ON title like '%' + dictionary + '%'
or

Code:
LEFT JOIN dbo.ToneDictionary D
  ON title like '%' + rtrim(ltrim(dictionary)) + '%'

and just as a note.. "ON CHARINDEX(Dictionary,Title) > 0" is a valid join condition

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
pressed submit too fast...

regardless of, the search always going to be slow as every record on Title needs to be retrieved and compared.


Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top