I've been working with PostGIS more lately and wanted to get a better handle on doing intersection operations specifically, I'm trying to intersect a set of polygons like zoning areas with another layer say, parcel boundaries to get a breakdown of how each parcel overlaps with the zones. I'm using ST_Intersection, but I've noticed performance can tank when the datasets are large, are there any tricks or best practices for speeding this up like using ST_Intersects first to filter, or prepping geometries somehow?
How do you usually handle cases where the result of the intersection needs to retain attributes from both original layers, do you do it all in one query, or break it up?
How do you usually handle cases where the result of the intersection needs to retain attributes from both original layers, do you do it all in one query, or break it up?