Performance on multiple OR conditions inside () - Mailing list pgsql-general

From Håvard Wahl Kongsgård
Subject Performance on multiple OR conditions inside ()
Date
Msg-id AANLkTingN4dwbSubov7_zbZ8+hxZTOsLGtci236yHbVV@mail.gmail.com
Whole thread Raw
List pgsql-general
Hi, I have a spatial query with multiple OR statements, for large tables it's very slow. Is it possible to skip the spatial lookup on the other conditions if first(previous) condition equal 1, and thereby increase the performance?
 
SELECT vciia_main.sitrp,vciia_main.date_time from vciia_main, south_vietnam72, roads, rails, houses, city where st_within(vciia_main.geom, south_vietnam72.geom) and date_time is not null and (st_dwithin(vciia_main.geom, roads.geom, 500) OR st_dwithin(vciia_main.geom, rails.geom, 500) or st_dwithin(vciia_main.geom, city.geom, 800) or st_dwithin(vciia_main.geom, houses.the_geom, 500))

--
Håvard Wahl Kongsgård
Peace Research Institute Oslo (PRIO)

http://havard.security-review.net/

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Record with a field consisting of table rows
Next
From: Tom Lane
Date:
Subject: Re: Record with a field consisting of table rows