all groups > sql server full text search > may 2005 >
You're in the

sql server full text search

group:

CONTAINS and LIKE


CONTAINS and LIKE Matias Woloski
5/11/2005 12:00:00 AM
sql server full text search:
Hillary, would you mind doing a small explanation on this post?
Thanks a lot!

It will do a clustered index scan. this is what it looks like.


StmtText
----------------------------------------------------------------------------
-------------------------
SELECT * from authors
WHERE
CONTAINS( *, 'keyworkd')
OR
au_lname LIKE '%keyworkd%'

(1 row(s) affected)

StmtText
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------
|--Filter(WHERE:(like([authors].[au_lname], '%keyworkd%', NULL) OR
[Expr1004]))
|--Nested Loops(Left Semi Join, WHERE:(like([authors].[au_lname],
'%keyworkd%', NULL))OUTER REFERENCES:([authors].[au_id]), DEFINE:([Expr1004]
= [PROBE VALUE]))
|--Clustered Index
Scan(OBJECT:([pubs].[dbo].[authors].[UPKCL_auidind]))
|--Filter(WHERE:([authors].[au_id]=[FULLTEXT:authors].[KEY]))
|--Table Spool
|--Remote Scan(OBJECT:(CONTAINS))

(6 row(s) affected)


Re: CONTAINS and LIKE Hilary Cotter
5/12/2005 9:34:48 AM
I didn't think you were being serious before.

Basically it does a remote scan of the full text catalog (|--Remote
Scan(OBJECT:(CONTAINS))), it then spools this data locally and does a join
against the authors table - scanning the au_id column using the auidind
index (this is a clustered index scan)

Scan(OBJECT:([pubs].[dbo].[authors].[UPKCL_auidind]))
|--Filter(WHERE:([authors].[au_id]=[FULLTEXT:authors].[KEY]))
|--Table Spool

It then does a nested loop against the authors table using the join (Left
Semi Join, WHERE:(like([authors].[au_lname], '%keyworkd%', NULL))

and filters the results.

Put this query in query analyzer and hit ctrl - L

and you can see it for yourself.



--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com

[quoted text, click to view]

Re: CONTAINS and LIKE Matias Woloski
5/12/2005 1:50:30 PM
Thanks Hilary for introducing me into this.

Now, I see the execution plan for this query and I see that 87% of the query
is the remote scan (contains).

I was concerned about the perf impact of having CONTAINS and LIKE both
together and it seems that is minimal.

What if I have 100k records? How the clustered index (like expr) would
perform? How compared to a query which only does a remote scan?

Thanks again for your help,
Matias


[quoted text, click to view]

Re: CONTAINS and LIKE Hilary Cotter
5/12/2005 10:03:29 PM
The nested loop is changed to a merge join

|--Filter(WHERE:(like([fulltext].[charcol], '%keyworkd%', NULL) OR
[Expr1004]))
|--Merge Join(Left Semi Join,
MERGE:([fulltext].[pk])=([FULLTEXT:fulltext].[KEY]),
RESIDUAL:([fulltext].[pk]=[FULLTEXT:fulltext].[KEY]) OR
like([fulltext].[charcol], '%keyworkd%', NULL))
|--Clustered Index
Scan(OBJECT:([pubs].[dbo].[fulltext].[primarykey]), ORDERED FORWARD)
|--Sort(ORDER BY:([FULLTEXT:fulltext].[KEY] ASC))
|--Remote Scan(OBJECT:(CONTAINS))

(5 row(s) affected)


--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com

[quoted text, click to view]

AddThis Social Bookmark Button