0

I have a transaction table where I am storing buy/sell transactions related information, and this information I am getting is from MQ as an XML and I am also storing XML String as VARCHAR(MAX) in SQL Server database.

The issue is that since I am storing XML String into this table, select query is running very slow.

Is there any way I can increase the performance? Any recommendation will be highly appreciated.

The solution which I can think of is to create another table of 1 -1 mapping with my transaction table to store XML String but not really sure if this is the best idea.

closed as too broad by Erik Darling, kevinsky, mustaccio, Josh Darnell, LowlyDBA May 7 at 17:25

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Can you provide some additional info, such as the query you're running, the execution plan, table DDL and so forth? Also, if you have example data and expected results that will help as well. – HandyD May 7 at 5:08
  • Please consider reading this advice – mustaccio May 7 at 13:06
1

If you can adjust the datatype of the column to XML and your table has a clustered primary key, you can potentially improve performance, but there are a few fundamental changes you'll need to ensure occur.

  1. Ensure your table is Clustered on the Primary Key. Your table must be clustered and the cluster key must also be your Primary Key.
  2. Strongly type your column as XML. Storing XML as character data eliminates any possibility to create an XML Index(es) on the column.

If you can satisfy these requirements, you can then take advantage of XML Indexes. I'm not going to go into the details of how these work or how you set them up, as you can easily find articles online that discuss this in more detail (ref1, ref2, ref3), but used properly these can dramatically improve performance of queries that have to interact with XML data.

Not the answer you're looking for? Browse other questions tagged or ask your own question.