Carl Hörberg
Carl Hörberg

Reputation: 6005

XQuery performance in SQL Server

Why does this quite simple xquery takes 10min to execute in sql server (the 2mb xml document stored in one column) compared to 14 seconds when using oxygen/file based querying?

SELECT model.query('declare default element namespace "http://www.sbml.org/sbml/level2";
for $all_species in //species, $all_reactions in //reaction
where data($all_species/@compartment)="plasma_membrane" and $all_reactions/listOfReactants/speciesReference/@species=$all_species/@id
return <result>{data($all_species/@id)}</result>') from sbml;

Upvotes: 0

Views: 2351

Answers (2)

Carl H&#246;rberg
Carl H&#246;rberg

Reputation: 6005

"//" kills MSSql, use a so exact path as possible instead: http://scarydba.wordpress.com/2009/11/30/xquery-for-idiots/

Upvotes: 5

Remus Rusanu
Remus Rusanu

Reputation: 294287

Do you have a schema declaration for your XML? Did you place appropiate indexes on it?

Upvotes: 1

Related Questions