Re: [postgis-users] Query choces on searching too small area

2016-12-19 Thread Arjen Haayman
photoId" FROM "photoMetadata" WHERE (key = 'year' AND ( cast(value as int ) >= 1866 AND cast ( value as int ) <= 1981)) ) , keeping_photo_id_in_both_set AS ( SELECT photoId FROM photos_spatialy_close INTERSECTS SELECT photoId FROM photo_with_

Re: [postgis-users] Query choces on searching too small area

2016-12-16 Thread Arjen Haayman
QUERY PLAN Limit (cost=27753.88..27753.89 rows=1 width=819) -> Sort (cost=27753.88..27753.89 rows=1 width=819) Sort Key: photo."photoDirId", photo.foto_nr -> Nested Loop Semi Join (cost=23473.88..27753.87 rows=1 width=819) Join Filter: (photo.id = public."p

Re: [postgis-users] Query choces on searching too small area

2016-12-16 Thread Arjen Haayman
when you execute separately the subqueries inside the where clause? Do these already take long to execute, do they use the indexes defined (tables are recently vacuum'ed?) and do they give back a sufficiently small number of ids to be selective? M. On 16-12-16 14:09, Arjen Haayman

[postgis-users] Query choces on searching too small area

2016-12-16 Thread Arjen Haayman
Hi, I've got this database that has photos that have a location and a table with key/value metadata. There are almost 450,000 photos and 5 million rows of metadata. Searching on metadata alone always works, but when I add a spatial search to it the query freezes if the spatial component is too