<div dir="ltr"><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>The inner join did the trick.  I didn't know what a performance hit the CTE was.  They just make it easier to read.</div><div>New Query:</div><div><br></div><div>select <a href="http://p1.id">p1.id</a> as src, <a href="http://p2.id">p2.id</a> as dest<br>from points p1<br>left join points p2 on st_dwithin(p1.geom,p2.geom,16*1.74)<br>where <a href="http://p1.id">p1.id</a> != <a href="http://p2.id">p2.id</a><br>and p1.geom > p2.geom<br></div><div><br></div><div>order of magnitude faster on big tables</div><div><br></div><div><br></div></div></div></div>