I have the SP I call the following example ways (the call is not from SQL rather it is from a .net program)
or
-- run with a few grantees
exec someproc 99999, '<grantees><grantee id="99"/><grantee id="100"/><grantee id="101"/></grantees>'
-- takes about 1 sec with > 59s on xml decomp
or perhaps
-- run with lots of grantees (approx 2000)
exec someproc 99999, '<grantees><grantee id="99"/><grantee id="100"/>....<grantee id="2001"/></grantees>'
-- takes about 5 sec with > 4s on xml decomp
or perhaps
-- run with mega loads of grantees (approx 12000)
exec someproc 99999, '<grantees><grantee id="99"/><grantee id="100"/>....<grantee id="12001"/></grantees>'
-- takes about 1 min with > 59s on xml decomp
And I'm finding that the xml decomposition is the slowest part (about 96% of the query in each case - and believe me I'm inserting/deleting/altering tonnes of data in the rest of the proc).
I'm very curious if my way of decomposing XML is the most optimal way for the given input sets. My criteria for using XML is simply to pass the SP a number of integers - so any suggestions for better ways are gratefully received.
create procedure someproc(@id int, @users xml = '<grantees/>') as
begin
-- decompose the users into a row set
declare @allUsers table (
id int
)
insert into @allUsers (id)
select distinct grantee.value('@id', 'int') uno
from @users.nodes('/grantees/grantee') grantees(grantee)
where isnull(grantee.value('@id', 'int'), 0) > 0
select * from @allUsers
-- other stuff happens
end