Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


XMLDocuments growing bigger


XMLDocuments growing bigger

Author
Message
SQLAddict01
SQLAddict01
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 395
I have a xml table in which it has 10 million records in it . Every day there will be approx 5000 files dumped into the table which is really slow. Can you suggest some best practices to improve the performance?
Steven Willis
Steven Willis
SSC-Addicted
SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)SSC-Addicted (477 reputation)

Group: General Forum Members
Points: 477 Visits: 1721
With that many rows now it will take time, but setting up XML indexes can make a HUGE difference. Without seeing how your XML is being stored I can't really offer much more than that. But say you have an XML column that has a typical entry like this:


CREATE TABLE [dbo].[!Test](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Col1] [int] NULL,
[Col2] [nvarchar](50) NULL,
[Col3] [xml] NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[!Test] ON
INSERT [dbo].[!Test] ([ID], [Col1], [Col2], [Col3]) VALUES (1, 2345, N'TEST', N'<code attribute="color" value="red" />')
INSERT [dbo].[!Test] ([ID], [Col1], [Col2], [Col3]) VALUES (2, 4566, N'TEST2', N'<code attribute="color" value="blue" />')
SET IDENTITY_INSERT [dbo].[!Test] OFF
use LocalTestDB
GO

ALTER TABLE [dbo].[!Test] ADD CONSTRAINT [PK_!Test] PRIMARY KEY CLUSTERED
([ID] ASC)

CREATE PRIMARY XML INDEX [IX_Test_XML]
ON [dbo].[!Test]([Col3])

CREATE XML INDEX [IX_Test_XML_Code]
ON [dbo].[!Test]([Col3])
USING XML INDEX [IX_Test_XML]
FOR PATH

CREATE XML INDEX [IX_Test_attribute]
ON [dbo].[!Test]([Col3])
USING XML INDEX [IX_Test_XML]
FOR PROPERTY

CREATE XML INDEX [IX_Test_color]
ON [dbo].[!Test]([Col3])
USING XML INDEX [IX_Test_XML]
FOR VALUE


SELECT TOP 1000 [ID]
,[Col1]
,[Col2]
,[Col3]
FROM [dbo].[!Test]




These are like any other indexes in that you may not need all three types or you may need more for additional properties. That will take some testing to see what effect the indexes have on your query plan. Test on a small chunk of that million-row table and when you have the indexes the way you want them they can be applied to the actual data.

 

 
SQLAddict01
SQLAddict01
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 395
Thanks for the reply. I thought of putting up XML Indexes, but the concern is the table is huge it will take a lot of time to create the indexes.. may be like 15-20 hours.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search