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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:29:00+00:00 2026-05-18T09:29:00+00:00

It’s crazy, but query performance is about 50% WORSE after I add a primary

  • 0

It’s crazy, but query performance is about 50% WORSE after I add a primary XML index to my xml field.

Here’s what I’m doing.

  • I have a table containing an XML field ActivityStepLog (contains LogData, XML)

  • I generate sample data to insert into this table by running the following

    INSERT INTO dbo.ActivityStepLog (
    LogGUID
    ,LogContextID
    ,LogTypeID
    ,LogSourceName
    ,LogContent
    ,LogDate
    ,CreateDate
    ,CreatedBy
    )
    select
    LogGUID = newid()
    ,LogContextID = newid()
    ,LogTypeID = 2
    ,LogSourceName = ‘test test test’
    ,LogContent = (SELECT top 1 * FROM ##SampleData SampleData1 where DecisionLogID = SampleData.DecisionLogID FOR XML AUTO, ELEMENTS, ROOT(‘BusinessRule’) )
    ,LogDate = current_timestamp
    ,CreateDate = current_timestamp
    ,CreatedBy = ‘test create by’
    from ##SampleData SampleData

SampleData has 100,000 rows, I run it in a loop 5 times so end up with 500,000 rows.

  • The LogContent field will end up having data such as the following:

    -2147483643
    0569281A-D1A3-49E3-9E68-BCAC62E2C1C3
    1016
    2
    0
    -2147483495
    1
    2009-05-18T11:47:00
    none

(sorry, not sure if this will be formatted properly – it’s just basically a short set of elements).

And then I just run a very simple sql –

SELECT *
FROM ActivityStepLog
WHERE LogContent.value('(/BusinessRuleDecisionLog/SampleData1/DecisionLogID)[1]', 'int') = -2147483535

Before creating the primary xml index on LogContent, it takes 8 seconds, after, it takes about 12 seconds. I’ve cleaned out cache, etc (DROPCLEANBUFFERS and FREEPROCCACHE ), it doesn’t seem to affect the proportions though it does affect the overall time.

Here’s my statistics:

WITH xml index
Table ‘xml_index_nodes_325576198_256000’. Scan count 1000000, logical reads 3517272, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table ‘ActivityStepLog’. Scan count 1, logical reads 71694, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

With OUT xml index

(5 row(s) affected)
Table ‘ActivityStepLog’. Scan count 1, logical reads 71694, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

So, the logical reads are much less withOUT the xml index. I tried adding ALL the available secondary indexes, that didn’t improve performance over having a primary xml index.

I’ll be doing some more research on this, but I would really appreciate any pointers or comments.

thanks,
Sylvia

  • 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-18T09:29:01+00:00Added an answer on May 18, 2026 at 9:29 am

    From doing more research on this – it appears that for UNTYPED xml fields, at least in my test case, the xml indexes degrade performance. This appears to be different for typed xml, though I didn’t look into it much.

    One thing that DID improve performance tremendously (thank you for the idea to wBob on the msdn sql xml forum!) was to create a full text index on the xml field. I got subsecond performance at that point. I also included an xml filter as well for accuracy.

    SELECT *
    FROM dbo.ActivityStepLog
    WHERE 
       CONTAINS (LogContent, '-2147483535')
       and LogContent.value('(/BusinessRuleDecisionLog/SampleData1/DecisionLogID)[1]', 'int') = -2147483535
    

    I sill need to research whether this fits all my filtering needs, but so far it looks good.

    Sylvia

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.