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 6189777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:28:20+00:00 2026-05-24T02:28:20+00:00

Consider the following situation: There is an xml that contains data @XmlData The @XmlData

  • 0

Consider the following situation:

  1. There is an xml that contains data @XmlData
  2. The @XmlData is extracted into a relational table (@ItemList)
  3. A table variable is defined (@Table)
  4. The data extracted from 2 db tables (tblCdbA0 and tblCdbG2) into @Table using exists clause

Here is a code sample:

--1. There is an xml that contains data @XmlData 
declare @XmlData xml = '
<Root>
      <Item rid="522822E251CA11D18F1400A02427D15E" />
</Root>'

--2. The @XmlData is extracted into a relational table (@ItemList)
declare @ItemList table (ItemRid char(32) primary key);
insert into @ItemList(ItemRid)
select Tab.rid
from ( select Item.Rid.value('@rid','char(32)') rid
       from @XmlData.nodes('(/Root)[1]/Item') Item(Rid)) Tab
group by Tab.rid

--3. A table variable is defined (@table)
declare @Table TABLE 
(
    Rid char(32) primary key
   ,Rid1 char(32)
   ,Rid2 char(32)
)

--4. The data extracted from 2 db tables (tblCdbA0 and tblCdbG2) into @Table using exists clause
insert into @Table(Rid,Rid1,Rid2)
select A0.A0RID, A0.T4RID, A0.T6RID
from tblCdbA0 A0 with (nolock)
where 
exists (select null 
         from tblCdbG2 G2 with(nolock)
         inner join @ItemList Items
         on Items.ItemRid = G2.G0RID 
         where A0.A0RID=G2.A0RID)

The table tblCdbG2 contains 63582 rows.
Let’s look what actual execution plan of the last statement shows us:

Query execution plan

The execution plan shows that number of data rows that are extracted from tblCdbG2 table equal to 807 rows instead of 63582.

In my view, the number of rows that are extracted from tblCdbG2 must be 63582. After inner join with @ItemList is applied the number of rows must be 807.

What is the reason to show already filtered rows number before inner join?

Update:

I have slightly modified the existing query and the plan shows the same value 807.

The query:

select G2.A0RID 
         from tblCdbG2 G2 with(nolock)
         inner join @ItemList Items
         on Items.ItemRid = G2.G0RID

The plan:

Slightly modified query in EXISTS

  • 1 1 Answer
  • 1 View
  • 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-24T02:28:20+00:00Added an answer on May 24, 2026 at 2:28 am

    The nested loop to left is pulling every row from @ItemList. For each row from @Item list it is using an index (Clustered Index Seek) to find just the matching row(s) in tblCdbG2. It does not first extract all 60+K rows.

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

Sidebar

Related Questions

Consider the following situation: I have an object foo that is used by multiple
Consider following situation: there is ComboBox and a filter TextBox, then user types a
Consider the following situation: There is a serialization file, created by the older version
Lets consider the following situation. There is products_controller which can be accessed from Admin
Consider the following situation: internet provider has a selfcare site that is integrated with
Consider the following situation: There is a master page with a contentPlaceHolder for all
Consider the following situation: I have a library that includes a third party library.
Consider the following (simplistic) situation: CREATE TABLE PARENT ( PARENT_ID INT PRIMARY KEY );
Consider the following situation Code was added to the trunk at revision x A
Consider the following situation: WidgetCompany produced a .NET DLL in 2006 called Widget.dll, version

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.