title: SQL Spatial Join - Null Values Causing Problems
body: <p>I have two tables with point data. 
  Table 1 - No null Points.<br>
  Table 2 - About half of the points are null.</p>
  
  <p>The query:</p>
  
  <pre><code>SELECT
    *
  FROM
    Table1 
  INNER JOIN
    Table2 
  ON
    Table1.Point.STBuffer(2.5).STIntersects(Table2.Point) = 1
  WHERE
    Table1.Point IS NOT NULL
    AND Table2.Point IS NOT NULL
  </code></pre>
  
  <p>Takes over 8 hours to complete.</p>
  
  <p>If I copy the data to a temporary table like this:</p>
  
  <pre><code>INSERT INTO TempTable SELECT * FROM Table2 WHERE Point IS NOT NULL
  </code></pre>
  
  <p>The same query takes about 40 seconds.</p>
  
  <p>If I add some null data back in.</p>
  
  <pre><code>INSERT INTO TempTable SELECT TOP 10000 * FROM Table2 WHERE Point IS NULL
  </code></pre>
  
  <p>It goes back to taking forever.</p>
  
  <p>What is happening?</p>