title: Which is faster .exist or .value in a where clause?
body: <p>I am doing some crude benchmarks with the xml datatype of SQL Server 2008. I've seen many places where <code>.exist</code> is used in <code>where</code> clauses. I recently compared two queries though and got odd results. </p>
  
  <pre><code>select count(testxmlrid) from testxml
  where Attributes.exist('(form/fields/field)[@id="1"]')=1
  </code></pre>
  
  <p>This query takes about 1.5 seconds to run, with no indexes on anything but the primary key(testxmlrid)</p>
  
  <pre><code>select count(testxmlrid) from testxml
  where Attributes.value('(/form/fields/field/@id)[1]','integer')=1
  </code></pre>
  
  <p>This query on the otherhand takes about .75 seconds to run. </p>
  
  <p>I'm using untyped XML and my benchmarking is taking place on a SQL Server 2008 Express instance. There are about 15,000 rows in the dataset and each XML string is about 25 lines long. </p>
  
  <p>Are these results I'm getting correct? If so, why does everyone use <code>.exist</code>? Am I doing something wrong and <code>.exist</code> could be faster?</p>