I'm currently trying to tune a somewhat problematic stored procedure and I've noticed that majority of cost associated with running it comes from parsing parsing some XML into a temp table. Here is the SQL in question:
CREATE TABLE #ChangeSet
(
RemarkTypeID TINYINT NOT NULL PRIMARY KEY,
RemarkText VARCHAR(2500) NOT NULL,
ListingID INT NOT NULL
)
INSERT INTO #ChangeSet
(RemarkTypeID,
RemarkText,
ListingID)
SELECT
T.c.value('@RemarkTypeID[1]','tinyint') AS RemarkTypeID,
T.c.value('@RemarkText[1]','varchar(2500)') AS RemarkText,
@ListingID
FROM @RemarksXml.nodes('/Remarks[1]/Remark') AS T(c)
Also, so you have some idea of the structure of the XML being parsed:
<Remarks>
<Remark xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RemarkID="211767" DateTimeCreated="1991-11-19T10:43:50" DateTimeModified="1992-01-01T10:43:50" RemarkTypeID="8" RemarkText="aaaWasher,Dryer,Refriger,Microwav" />
<Remark xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RemarkID="211768" DateTimeCreated="1991-11-19T10:43:50" DateTimeModified="1992-01-01T10:43:50" RemarkTypeID="3" RemarkText="aaaell Maintained 3Bd 1.5Ba Semi-Detached Home In Cambridge Gardens. Garage W As Converted Into A Nice Family Room The Outside Is Maintence Free. Includes All Appliances,Security System,Storage Shed,Ceiling Fans And New Carpet.This Home Is Very Well Pricded. Seller Will Consider Fha Or Va Along With Conventional Finacing. This Is A Great Buy." />
</Remarks>
Is there anything I can do to improve the performance of parsing these XML nodes and setting up this temp table?