Hi David,<br>you can use "except" instead of "not in", the query should be changed to:<br><br>SELECT survey.parcelnum<br>
FROM survey<br>
<b>except</b><br>
(SELECT parcel_esri.parcelnum<br>
FROM parcels_esri)<br><br>I think the query above will be faster than the old one. After you had survey.parcelnum, you can do something with these.<br><br>Cheers.<br><br><div class="gmail_quote">On Sun, Jul 25, 2010 at 4:09 AM, David Epstein <span dir="ltr"><<a href="mailto:davideps@umich.edu">davideps@umich.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I have one spatial table and one non-spatial table each with about 380k<br>
rows. They can be joined by "parcelnum". However, there are some parcel<br>
numbers in each table that do not match. I want the full rows of the<br>
non-matching from each. I've made a standard (b-tree) index for<br>
"parcelnum" in both tables and then ran this query to get non-matching<br>
rows in a single direction:<br>
<br>
SELECT *<br>
FROM survey<br>
WHERE survey.parcelnum NOT IN<br>
(SELECT parcel_esri.parcelnum<br>
FROM parcels_esri)<br>
<br>
This query has already run for 35 minutes and is still running. I have a<br>
laptop running Ubuntu 9.04 64bit with two P8700 2.53GHz CPUs and 3.8GB<br>
of memory. Only 1 CPU and 1.3GB of memory is being used. Is there<br>
anything I can do to speed up not-in (and join) queries?<br>
<br>
thank you,<br>
<font color="#888888">-david<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>
<div style="margin: 0in 0in 0pt;"><b><span style="color: rgb(31, 73, 125); font-size: 8pt;"><font face="Calibri">Liem Nguyen (DBA)<br><br>AXON ACTIVE 
VIETNAM</font></span></b></div>
<div style="margin: 0in 0in 0pt;"><b><span style="color: rgb(31, 73, 125); font-size: 8pt;" lang="DE-CH"><a href="http://www.axonactive.vn/" target="_blank"><span lang="EN-US"><font color="#0000ff" face="Calibri">www.axonactive.vn</font></span></a></span></b><b><span style="color: rgb(31, 73, 125); font-size: 8pt;"></span></b></div>

<div style="margin: 0in 0in 0pt;"><span style="color: rgb(31, 73, 125); font-size: 8pt;"><font face="Calibri"> </font></span></div>
<div style="margin: 0in 0in 0pt;"><span style="color: rgb(31, 73, 125); font-size: 8pt;"><font face="Calibri">10th Floor, Hai Au 
Building, 39B Truong Son, Ward 4, Tan Binh District, Ho Chi Minh City, 
Vietnam</font></span></div>
<div style="margin: 0in 0in 0pt;"><span style="color: rgb(31, 73, 125); font-size: 8pt;"><font face="Calibri">T +84 8 629 738 59, F 
+84 8 381 134 89, M +84 168 994 8897</font></span></div>
<div style="margin: 0in 0in 0pt;"><span style="font-size: 8pt;"><font size="1"><u>8897 +10° 48' 32.72", +106° 39' 
51.58"</u></font></span></div><pre><br></pre></div><br>