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

  • SEARCH
  • Home
  • 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 45803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:51:59+00:00 2026-05-10T15:51:59+00:00

The Query Optimizer is estimating that the results of a join will have only

  • 0

The Query Optimizer is estimating that the results of a join will have only one row, when the actual number of rows is 2000. This is causing later joins on the dataset to have an estimated result of one row, when some of them go as high as 30,000.

With a count of 1, the QO is choosing a loop join/index seek strategy for many of the joins which is much too slow. I worked around the issue by constraining the possible join strategies with a WITH OPTION (HASH JOIN, MERGE JOIN), which improved overall execution time from 60+ minutes to 12 seconds. However, I think the QO is still generating a less than optimal plan because of the bad rowcounts. I don’t want to specify the join order and details manually– there are too many queries affected by this for it to be worthwhile.

This is in Microsoft SQL Server 2000, a medium query with several table selects joined to the main select.

I think the QO may be overestimating the cardinality of the many side on the join, expecting the joining columns between the tables to have less rows in common.

The estimated row counts from scanning the indexes before the join are accurate, it’s only the estimated row count after certain joins that’s much too low.

The statistics for all the tables in the DB are up to date and refreshed automatically.

One of the early bad joins is between a generic ‘Person’ table for information common to all people and a specialized person table that about 5% of all those people belong to. The clustered PK in both tables (and the join column) is an INT. The database is highly normalized.

I believe that the root problem is the bad row count estimate after certain joins, so my main questions are:

  • How can I fix the QO’s post join rowcount estimate?
  • Is there a way that I can hint that a join will have a lot of rows without specifying the entire join order manually?
  • 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. 2026-05-10T15:52:00+00:00Added an answer on May 10, 2026 at 3:52 pm

    Although the statistics were up to date, the scan percentage wasn’t high enough to provide accurate information. I ran this on each of the base tables that was having a problem to update all the statistics on a table by scanning all the rows, not just a default percentage.

    UPDATE STATISTICS <table> WITH FULLSCAN, ALL 

    The query still has a lot of loop joins, but the join order is different and it runs in 2-3 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have have a query that is performing poorly. One aspect of the query
I'm trying to optimize query performance and have had to resort to using optimizer
I understand that the WITH RECOMPILE option forces the optimizer to rebuild the query
I have a search query that I'm inheriting and attempting to optimize. I am
This query is related to this one I asked yesterday. I have a radio
Say I have a query like the one below: SELECT t1.id, t1.Name FROM Table1
I have this query: SELECT * FROM sample INNER JOIN test ON sample.sample_number =
Here is the issue I am having: I have a large query that needs
I have this query that is optimized for speed (that's why it might look
I have a monster legacy query that is in the core of my program,

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.