Select the product you need help with
Improve the performance of full-text queries in SQL ServerArticle ID: 2549443 - View products that this article applies to. SummaryThis article describes a method to improve the performance of Microsoft SQL Server queries that use full-text search predicates (such as CONTAINS and CONTAINSTABLE) and that also filter data. For example, this method improves the performance of the following query: More informationWhen you create a full-text search query, the principle factor that affects the performance of the query is the quantity of data that the full-text search engine must process before the remaining data is sent to the relational engine. In SQL Server, you can improve the performance of the query by filtering out rows early to reduce the number of rows that must be processed later. In versions of SQL Server that were released before SQL Server 2008, the full-text search engine returns all the rows that match a search term, and then the relational engine applies any filters. Improvements to this behavior were made in SQL Server 2008, in SQL Server 2008 R2, and in SQL Server 2012. However, it is difficult to use these improvements because full-text search indexes are organized very differently from database indexes. Additionally, the full-text search engine and the relational engine work very differently. Therefore, the method that this article describes uses the Table-Valued Function (TVF) to filter out rows early and to reduce the number of rows that must be processed later. For example, the following query plan returns 131051 rows that match a CONTAINS search string. Additionally, a join operator in the plan performs additional filtering by using an index seek. If a predicate contains a DateTime data type column, you can include date information in the unique index key column so that only the rows that match this predicate are emitted. To do this, you must logically incorporate the date information in the key column. However, you may also have to change the key column data type and applications that use the query. To implement the method, change the data type of the full-text unique key ID to BIGINT. The first 4 bytes of the key ID capture the year, month, and date values from the date column, and the last 4 bytes remain the same. For example, the first byte of the key ID could refer to the year, the next byte could refer to the month, and the last two bytes could refer to the date. The application must accommodate this data type change. Then, translate a range predicate to a predicate on the key ID. For example, the "x < CDate< y" range predicate can be translated to the "(x*2^32 < ID < y*2^32)" predicate. Because the translated predicate is a predicate on the full-text key, the predicate will be pushed down into the full-text Streaming Table-Valued Functions (STVF). This behavior effectively performs searches within the date range. PropertiesArticle ID: 2549443 - Last Review: March 22, 2013 - Revision: 3.0 Applies to
| Article Translations
|


Back to the top








