<div dir="ltr">Hello,<div>I am having trouble with what I expected to be a simple query. I have two tables, one of census tracts (with a multipolygon geometry column, srid 4269), and another of sites (with a point geometry column, srid 4269). I want to find the number of sites that are within a tract of more than a given population, so I've tried:</div><div><br></div><div><div>SELECT count(<a href="http://sites.id">sites.id</a>) FROM sites, census_tracts WHERE AND census_tracts.population > 2000 AND ST_Contains(census_tracts.geometry, sites.location);</div></div><div><br></div><div>But when I do this I get: psycopg2.InternalError: invalid join selectivity: 179531936.000000.</div><div><br></div><div>Both of the relevant tables have been analyzed and vacuumed. </div><div><br></div><div>The output of postgis_full_version() is </div><div><br></div><div><div>POSTGIS="2.1.8 r13780" GEOS="3.4.2-CAPI-1.8.2 r3924" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.11.1, released 2014/09/24" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER</div></div><div><br></div><div>I'm using Windows 7.</div><div><br></div><div>Does this ring a bell for anyone? </div><div><br></div><div>Thanks very much!</div><div><br></div><div>-Paul</div></div>