I am using QGIS to create a layer comprised of counties in 7 northeast US states.
I start with the US census 5M cartographic state borders file, and then set a filter on that layer:
"NAME" in (
'New York',
'Massachusetts',
'Rhode Island',
'Connecticut',
'New Hampshire',
'Vermont',
'Maine'
)
That gives me a layer with seven features. I wanted to take the US census 5M cartographic county borders file and restrict that to the same geographic area. I thought I could do it by setting up a virtual layer and setting up a spatial join, like this:
select a.*
from cb_2018_us_county_5m as a
join cb_2018_us_state_5m as b
on (st_contains(b.geometry, a.geometry))
That works, but it takes 5 or 6 seconds to render the county outlines; I can watch as they show up one by one. Given the relatively small number of features involved in this operation, I was surprised by the performance. Am I doing something suboptimal? The same query in, say, PostGIS is a sub-second operation.