I have a tbl_Data table in MS SQL Server 2008, which having two fields, ID is primary Key and CustomFields column can have XML Data.
[ID] [uniqueidentifier] [CustomFields] [xml] NULL
Average nodes in XML - 25 nodes in each record (some records having null, some having up to 70 nodes) Total Record count in tbl_Data : 80000 rows.
Below is a sample data for CustomFields Column.
<Fields>
<Field Id="StatusName" Value="Approve" />
<Field Id="LogNumber" Value="70470" />
<Field Id="SubmittedDate" Value="Feb 7 2012 12:00AM" />
..
<Fields>
I am trying to execute below query for retrieve records which having LogNumber 70470, This Query taking 1 Minute to generate result.
SELECT ID FROM [tbl_Data] WHERE CustomFields.exist('/Fields/Field[@Title = "LogNumber"]') = 1 AND CustomFields.exist('/Fields/Field[@Value="70470"]') = 1
I have tried to apply XML Index, but seems was not helpful.
Your valuable suggestion or advice is most welcome which you think for improve data retrieval performance i.e. Do I need to change XML structure?
Thanks Suresh