[postgis-users] Query choces on searching too small area
pramsey at cleverelephant.ca
Fri Dec 16 09:59:58 PST 2016
(a) I'm curious what happens when you unroll all those embedded subqueries
and let the planner try to do what it does best, something like this:
SELECT DISTINCT ON (photo.id)
ST_AsText(photo.geometry) AS geometry,
ST_AsText(photo.center) AS center,
JOIN "photoMetadata" meta
ON photo.id = meta."photoId"
WHERE (key = 'source' AND value = 'KADASTER')
AND (key = 'year' AND value::int BETWEEN 1866 AND 1981)
AND ST_Intersects(photo.geometry, ST_SetSRID(ST_MakePoint(4.5063099203616,
ORDER BY photo.filenam
(b) You should strongly consider changing your metadata table from the
key/value table into a jsonb table, with the metadata in JSON. Then for
things like date, and source, you can build functional indexes to allow
fast filtering on those common metadata fields, while still allowing fully
free-form metadata objects. This would make the whole thing both simpler
and a lot faster.
On Fri, Dec 16, 2016 at 8:48 AM, Sandro Santilli <strk at kbt.io> wrote:
> On Fri, Dec 16, 2016 at 03:33:32PM +0100, Arjen Haayman wrote:
> > QUERY PLAN
> > What does this tell you?
> That your query is too complex ?
> Check out http://explain.depesz.com
> postgis-users mailing list
> postgis-users at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the postgis-users