I posted this message some time ago on
microsoft.public.sqlserver.programming but got no replies. Today I
found this group so maybe I'll have better luck :)
I have a table with a full-text index on a given column. If I run the
following:
declare @s varchar(100)
select @s = 'fast'
select * from tblHannahRES where contains(RES_SER_TI, @s)
select * from tblHannahRES where contains(RES_SER_TI, 'fast')
on my SQL2000/SP4 box I get substantially different access times, which
is unlike what I would get with a normal index i.e. performing the SQL
below (where the index is on ResID) yields identical plans and access
times:
declare @i int
select @i = 1463440
select * from tblHannahRES where ResID = @i
select * from tblHannahRES where ResID = 1463440
With the full-text indices I get the plans shown below and the second
query is consistenly 6X faster than the first.
One thing I notice is that the remote scan itself costs 0.36 vs 0.06
though both generate the same number of rows. the second thing to
notice is that the first case incurs an extra sorting step (which costs
about 0.02 points). I'm not sure why this should be the case. Can
anyone elucidate on the issue here?
TIA - e
select * from tblHannahRES where contains(RES_SER_TI, @s)
|--Nested Loops(Inner Join, OUTER
REFERENCES:([FULLTEXT:tblHannahRES].[KEY]) WITH PREFETCH)
|--Sort(ORDER BY:([FULLTEXT:tblHannahRES].[KEY] ASC))
| |--Remote Scan(OBJECT:(CONTAINS))
|--Clustered Index
Seek(OBJECT:([Merlin].[dbo].[tblHannahRES].[PK_tblHannahRES]),
SEEK:([tblHannahRES].[ResID]=[FULLTEXT:tblHannahRES].[KEY]) ORDERED
FORWARD)
select * from tblHannahRES where contains(RES_SER_TI, 'fast')
|--Nested Loops(Inner Join, OUTER
REFERENCES:([FULLTEXT:tblHannahRES].[KEY]) WITH PREFETCH)
|--Remote Scan(OBJECT:(CONTAINS))
|--Clustered Index
Seek(OBJECT:([Merlin].[dbo].[tblHannahRES].[PK_tblHannahRES]),
SEEK:([tblHannahRES].[ResID]=[FULLTEXT:tblHannahRES].[KEY]) ORDERED
FORWARD)
Hilary Cotter - 26 May 2006 02:14 GMT
These are the plans I get on an equivalent machine. They are identical.
Could you post your schema.
StmtText
-----------------------------------------------------
set showplan_text on
declare @s varchar(100)
select @s = 'fast'
select * from authors where contains(au_lname, @s)
(3 row(s) affected)
StmtText
--------------------------------------------------------------------------------------------------------------------------------------------
|--Hash Match(Left Semi Join,
HASH:([authors].[au_id])=([FULLTEXT:authors].[KEY]),
RESIDUAL:([authors].[au_id]=[FULLTEXT:authors].[KEY]))
|--Clustered Index
Scan(OBJECT:([pubs].[dbo].[authors].[UPKCL_auidind]))
|--Remote Scan(OBJECT:(CONTAINS))
(3 row(s) affected)
StmtText
------------------------------------------------------------
select * from authors where contains(au_lname, 'fast')
(1 row(s) affected)
StmtText
--------------------------------------------------------------------------------------------------------------------------------------------
|--Hash Match(Left Semi Join,
HASH:([authors].[au_id])=([FULLTEXT:authors].[KEY]),
RESIDUAL:([authors].[au_id]=[FULLTEXT:authors].[KEY]))
|--Clustered Index
Scan(OBJECT:([pubs].[dbo].[authors].[UPKCL_auidind]))
|--Remote Scan(OBJECT:(CONTAINS))
(3 row(s) affected)

Signature
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
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
>I posted this message some time ago on
> microsoft.public.sqlserver.programming but got no replies. Today I
[quoted text clipped - 49 lines]
> SEEK:([tblHannahRES].[ResID]=[FULLTEXT:tblHannahRES].[KEY]) ORDERED
> FORWARD)