Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 762839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:27:37+00:00 2026-05-14T16:27:37+00:00

The Product table has 700K records in it. The query: SELECT TOP 1 ID,

  • 0

The Product table has 700K records in it. The query:


SELECT TOP 1 ID,
Name
FROM Product
WHERE contains(Name, '"White Dress"')
ORDER BY DateMadeNew desc

takes about 1 minute to run. There is an non-clustered index on DateMadeNew and FreeText index on Name.

If I remove TOP 1 or Order By – it takes less then 1 second to run.

Here is the link to execution plan.
http://screencast.com/t/ZDczMzg5N

Looks like FullTextMatch has over 400K executions. Why is this happening? How can it be made faster?

UPDATE 5/3/2010

Looks like cardinality is out of whack on multi word FreeText searches:

Optimizer estimates that there are 28K records matching ‘White Dress’, while in reality there is only 1.
http://screencast.com/t/NjM3ZjE4NjAt

If I replace ‘White Dress’ with ‘White’, estimated number is ‘27,951’, while actual number is ‘28,487’ which is a lot better.

It seems like Optimizer is using only the first word in phrase being searched for cardinality.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:27:38+00:00Added an answer on May 14, 2026 at 4:27 pm

    Edit

    From http://technet.microsoft.com/en-us/library/cc721269.aspx#_Toc202506240

    The most important thing is that the
    correct join type is picked for
    full-text query. Cardinality
    estimation on the FulltextMatch STVF
    is very important for the right plan.
    So the first thing to check is the
    FulltextMatch cardinality estimation.
    This is the estimated number of hits
    in the index for the full-text search
    string. For example, in the query in
    Figure 3 this should be close to the
    number of documents containing the
    term ‘word’. In most cases it should
    be very accurate but if the estimate
    was off by a long way, you could
    generate bad plans. The estimation for
    single terms is normally very good,
    but estimating multiple terms such as
    phrases or AND queries is more complex
    since it is not possible to know what
    the intersection of terms in the index
    will be based on the frequency of the
    terms in the index. If the cardinality
    estimation is good, a bad plan
    probably is caused by the query
    optimizer cost model. The only way to
    fix the plan issue is to use a query
    hint to force a certain kind of join
    or OPTIMIZE FOR.

    So it simply cannot know from the information it stores whether the 2 search terms together are likely to be quite independent or commonly found together. Maybe you should have 2 separate procedures one for single word queries that you let the optimiser do its stuff on and one for multi word procedures that you force a “good enough” plan on (sys.dm_fts_index_keywords might help if you don’t want a one size fits all plan).

    NB: Your single word procedure would likely need the WITH RECOMPILE option looking at this bit of the article.

    In SQL Server 2008 full-text search we have the ability to alter the plan that is generated based on a cardinality estimation of the search term used. If the query plan is fixed (as it is in a parameterized query inside a stored procedure), this step does not take place. Therefore, the compiled plan always serves this query, even if this plan is not ideal for a given search term.

    Original Answer

    Your new plan still looks pretty bad though. It looks like it is only returning 1 row from the full text query part but scanning all 770159 rows in the Product table.

    How does this perform?

    CREATE TABLE #tempResults
    (
    ID int primary key,
    Name varchar(200),
    DateMadeNew datetime
    )
    
    INSERT INTO #tempResults
    SELECT 
          ID, Name, DateMadeNew 
          FROM Product 
          WHERE contains(Name, '"White Dress"')
    
    
    SELECT TOP 1
        *
        FROM #tempResults
        ORDER BY DateMadeNew desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: **Product** ID Name SKU **Brand** ID Name Product table has
My Access table has product name and price for each record. I want to
I have a table name Product and another table name category. Product table has
Need to fetch data from a few tables -table one has all product details
I have a cart table which has a relation to a product table that
Which is your preference? Let's say we have a generic Product table that has
Imagine the following database: Table 'companies' has fields id, name and flagship_product_id. Table 'products'
I have a table [Product] with a column [CreateTime] datetime null, and is has
I have a Product table that has a column OrderStatusID . Here's an example
I have a product table that has a many-to-many relation to itself (using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.