Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

FULL text search Expand / Collapse
Author
Message
Posted Wednesday, December 12, 2012 3:54 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
Do we get any benefit if we choose to use full text search over like operator.

see the below queries with the stats
select  top 10000 * from [Person].[Person_BK] where 
contains([Name], 'fsfsfs')

select top 10000 * from [Person].[Person_BK] where
[Name] like '%fsfsfs%'

Stats

(10000 row(s) affected)
Table 'Person_BK'. Scan count 0, logical reads 30634, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

(1 row(s) affected)

(10000 row(s) affected)
Table 'Person_BK'. Scan count 1, logical reads 13464, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

(1 row(s) affected)


table defintion

CREATE TABLE [Person].[Person_BK](
[BusinessEntityID] [int] identity NOT NULL,
[PersonType] [nchar](2) NOT NULL,
[NameStyle] [dbo].[NameStyle] NOT NULL,
[Title] [nvarchar](8) NULL,
[Name] [nvarchar](max) NULL,
[Suffix] [nvarchar](10) NULL,
[EmailPromotion] [int] NOT NULL,
[AdditionalContactInfo] [xml] NULL,
[Demographics] [xml] NULL,
[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[ModifiedDate] [datetime] NOT NULL,
CONSTRAINT [PK_Person_BusinessEntityID_bk] PRIMARY KEY CLUSTERED
(
[BusinessEntityID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE FULLTEXT CATALOG catalog_fulltext_test
WITH ACCENT_SENSITIVITY = OFF




CREATE FULLTEXT INDEX ON [Person].[Person_BK] (Name LANGUAGE 1033)
KEY INDEX PK_Person_BusinessEntityID_bk ON catalog_fulltext_test
WITH STOPLIST = SYSTEM

i am not sure how we get benefits from full text from performance perspective ? please guide.

NOte : Everything is on same DISK (index + table + fulltext index )


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1395564
Posted Wednesday, December 12, 2012 3:57 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 6:52 AM
Points: 5,131, Visits: 4,918
Well the second one will use a scan as its not SARG-able due to it being '%...%'

What is the output with statistics time switched on and also what do the executions plans show.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395567
Posted Wednesday, December 12, 2012 4:06 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
anthony.green (12/12/2012)
What is the output with statistics time switched on and also what do the executions plans show.


SQL Server parse and compile time:
CPU time = 16 ms, elapsed time = 30 ms.

SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.

SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.

full text
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
Table 'Person_BK'. Scan count 0, logical reads 30634, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
CPU time = 500 ms, elapsed time = 1516 ms.

nomral
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
Table 'Person_BK'. Scan count 1, logical reads 16216, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
CPU time = 1094 ms, elapsed time = 2648 ms.


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done


  Post Attachments 
Capture.PNG (4 views, 30.89 KB)
Post #1395570
Posted Wednesday, December 12, 2012 4:09 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 6:52 AM
Points: 5,131, Visits: 4,918
Well the full text is faster on time, yes it reads more pages from memory than the like, but doesnt do a scan which the like does, so full text wins on that one for me. Also Full text is less cost than the like so again, that shows it is better.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395575
Posted Wednesday, December 12, 2012 4:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
anthony.green (12/12/2012)
but doesnt do a scan which the like does, so full text wins on that one for me.
well i think its because there is full text index on name column


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1395576
Posted Wednesday, December 12, 2012 4:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 6:52 AM
Points: 5,131, Visits: 4,918
Thats the whole point.

%...% will cause a table scan no matter what indexes you have on it

FTS will do the seek and then a match on the FTI




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395577
Posted Wednesday, December 12, 2012 4:18 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
anthony.green (12/12/2012)
Thats the whole point.

%...% will cause a table scan no matter what indexes you have on it

FTS will do the seek and then a match on the FTI
ok so you mean here that we are good with the stats , full text gives us edge ok thanks , have you seen the exec plan too ( attached in my third last post .. capture.png) .


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1395582
Posted Wednesday, December 12, 2012 4:25 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 6:52 AM
Points: 5,131, Visits: 4,918
yes I saw the execution plan, should upload them as SQLPLAN files as we can then open then in SSMS and naviagte the objects and see the stats, but as they are pretty simple, you can see that full text is the better plan



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395584
Posted Wednesday, December 12, 2012 4:26 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
anthony.green (12/12/2012)
yes I saw the execution plan, should upload them as SQLPLAN files as we can then open then in SSMS and naviagte the objects and see the stats, but as they are pretty simple, you can see that full text is the better plan
i always do and prefer but today i am using VDI so cant be able to thats y i took the screenshot


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1395586
Posted Thursday, December 13, 2012 4:27 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
during my testing or learning on Full text search , i found below queries are returning different results .can you please guide me why

select [BusinessEntityID] , [Name] from [Person].[Person_BK]
where contains([Name], ‘*ASDGDE*’) or contains([Name], ‘*AFASFA*’)

select [BusinessEntityID] , [Name] from [Person].[Person_BK]
where [Name] like ‘%ASDGDE%’ or [Name] like ‘%AFASFA%’



-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1396109
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse