- PostgreSQL
I executed below query for 4 million of geometry polygon in PostgreSQL. It took unlimited time which I need to stop the execution after 2 hour.
SELECT
c.id,
c.classification,
ST_Difference(b.geom, c.geom)
FROM
public."city" c,
public.b
where
c.classificationin ('Class I','Sub Metro City','Class II','Metro City','Class III','Mega City');
- QGIS
The same layer I used in QGIS using Difference in Vector >> Geoprocessing Tools and it took hardly 3 minutes to clip the region.
Please help me out
how can i optimize the query in PostgreSQL ?
EXPLAIN QUERYshow the query planner is doing? Also, make sure the code you are really running is what is above - fix the typos. – BradHards Aug 29 '16 at 07:17