SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Training
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
SQL Azure
Developer
General DBA
ASP.NET / ADO.NET
SQL Azure

USEFUL SITES :

ASP.NET Tutorials
Windows and SQL Azure Tutorials
Cloud Hosting Magazine
SharePoint Tutorials
Windows Server Help

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server

More     
 
Latest FAQ's

Add Node to A SQL Server failover Cluster failed with invalid ...
SQL Server Destination remote server error
Setting Up Data And Log Files For SQL Server
Will Check Constraints Improve Database Performance?

More     
   
Latest Software Reviews

dbForge Review
Spotlight on ApexSQL Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Data Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Doc 2008

More     

articles >> performance tuning >> SQL Server Full Text Search Optimization ...

SQL Server Full Text Search Optimization

By : Tony Bain
Mar 25, 2001

Page 2 / 2

To be honest, there is no elegant way to improve the performance. However, in certain situations you can dramatically improve the performance of a full text query by embedding textual codes within the text column. This will allow you to search both on your embedded textual code and the required search condition. This can reduce the number of rows returned to SQL greatly and change the performance of the full-text query by an order of magnitude.

For example if your data is:

PropertyID Type Description
1 HOUSE Big, Nice, Tidy, Shower, Kitchen 
2 FLAT Small, Tidy, Shower, Bath, Gas
3 HOUSE Medium, Average Quality, Bath
......    

update it to:

PropertyID Type Description
1 HOUSE TYPEHOUSE Big, Nice, Tidy, Shower, Kitchen 
2 FLAT TYPEFLAT Small, Tidy, Shower, Bath, Gas
3 HOUSE TYPEHOUSE Medium, Average Quality, Bath
......    

now you can rewrite your query to the following:

SELECT top 10 *
FROM properties p
INNER JOIN containstable(properties,'"TYPEFLAT" and "bath"') t
ON p.PropertyID = t.[key]
WHERE p.type = 'flat'

For this example, only 2,000 results will be returned to the Query Optimizer, and from this the top 10 rows will be returned to the user. This may be acceptable performance, however, if we run the following query:

SELECT top 10 *
FROM properties p
INNER JOIN containstable(properties,'"TYPEHOUSE" and "bath"') 
ON p.PropertyID = t.[key]
WHERE p.type = 'HOUSE'

In this example, 330,000 rows will be returned to the Query Optimizer, which means performance will still be poor. However, now that we are filtering the results in the Search Service before they are returned to the Query Optimizer, we can specify the number of results we need by using the top_n_by_rank parameter of the containstable function. So rewritten, this query would look like:

SELECT *
FROM properties p
INNER JOIN containstable(properties,'"TYPEFLAT" and "bath"',10) t
ON p.PropertyID = t.[key]
WHERE p.type = 'flat'

Obviously, you don't want to return the "TYPEFLAT" text in the description column to your database applications, so the final query should look like:

SELECT PropertyID, Type, SubString(description, 9, 9 - LEN(description)) AS description
FROM properties p
INNER JOIN containstable(properties,'"TYPEFLAT" and "bath"',10) t
ON p.PropertyID = t.[key]
WHERE p.type = 'flat'

In this example only 10 rows will be returned the Query Optimizer, so performance should ROCK!  

Obviously you will need to maintain the text code in the full-text column by using triggers, however the overhead in doing so should be minimal when compared to the speed performance gained.




Published with the express written permission of the author. Copyright 2000 Tony Bain.


<< Prev Page         








C# Help and Tutorials | PHP MySQL Tutorial | Sharepoint Tutorial | Azure Tutorial | Cloud Hosting Magazine | ASP.NET Tutorials | Windows Server Help | Windows Phone Pro | Silverlight Ace | Visual Studio Tutorials | Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | SQL Server Training Videos | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 2010 Jude O'Kelly. All rights reserved