XML input data query
The query cost calculated for a query is an estimate. Even in the actual execution plan it is the estimated cost that is shown.

For some reason SQL Server Management Studio uses those estimated costs and comes up with a cost percentage for each query in a batch.

Generally speaking that percentage has nothing to do with the actual performance of the query and should (in my opinion) not be used.

Estimates are based on statics of the involved tables and columns but XML variables (and columns) does not have any statistics that describe what shape for form they have so for XML queries the estimates are even less useful then for other types of queries.

Measure the actual performance instead like duration and IO.


  suggest a more efficient way of writing it


Nothing comes to mind that would improve the performance of your query so until you actually see a performance issue with this query you could use it as is. Provided it does return what you want.