I have two PostGIS tables containing thousands of geographic polygons each (each row has one polygon and numerous other attributes). Both tables represent different data sets but cover the same area of interest.
I'm trying to receive the rows of table A that intersect with rows from table B (meaning that the geometries intersect).
What I tried is the following:
SELECT tableA.polygon FROM tableA, tableB
WHERE ST_Intersects(tableA.polygon, tableB.polygon)=true;
I have no idea if this works or not since the query has not finished since I started it the first time 20 minutes ago. I have to admit that I'm running the query on a machine which is not very powerful.
Is this the correct way to do it? Is there a smarter or more effective way allowing me to reduce the computing time?
JOIN
on the smaller table (which should be indexed), with theWHERE
made into the JOIN constraint.