Sven Geggus schrieb:
Peter Körner <osm-lists@mazdermind.de> wrote: Der einzige Overhead der bleibt ist also die eigentliche Berechnung des centeroid und das kanns ja wohl nicht wirklich sein.
Nun wie Tobias schon feststellte, sind es zwei dinge: ST_IsValid und ST_PointOnSurface. ich habe ein paar tests gemacht (s. Anhang). Ergebnis bei 100000 Zeilen: nur way abfragen: 657.149 ms (x1) mit ST_IsValid: 8754.785 ms (x13) mit ST_IsValid und ST_PointOnSurface: 30616.056 ms (4658% - x46) Das heißt, dass eine Abfrage, die den geometrischen Mittelpunkt berechnet, 46x langsamer ist als ein einfaches Abfragen des Weges. Das lohnt sich denke ich also schon. Die Idee mit dem Trigger finde ich nicht schlecht, werde das bei Gelegenheit mal testen. Lg, Peter osm_mapnik=> explain analyze select way from planet_polygon limit 100000; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=0.00..6051.34 rows=100000 width=1692) (actual time=0.015..628.778 rows=100000 loops=1) -> Seq Scan on planet_polygon (cost=0.00..829926.48 rows=13714748 width=1692) (actual time=0.013..572.862 rows=100000 loops=1) Total runtime: 657.149 ms (3 rows) osm_mapnik=> explain analyze select way from planet_polygon where ST_IsValid(way) limit 100000; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.00..93154.04 rows=100000 width=1692) (actual time=0.110..8719.331 rows=100000 loops=1) -> Seq Scan on planet_polygon (cost=0.00..4258613.48 rows=4571582 width=1692) (actual time=0.109..8650.261 rows=100000 loops=1) Filter: st_isvalid(way) Total runtime: 8754.785 ms (4 rows) osm_mapnik=> explain analyze select ST_PointOnSurface(way) from planet_polygon where ST_IsValid(way) limit 100000; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.00..118154.04 rows=100000 width=1692) (actual time=0.516..30578.418 rows=100000 loops=1) -> Seq Scan on planet_polygon (cost=0.00..5401508.98 rows=4571582 width=1692) (actual time=0.513..30505.566 rows=100000 loops=1) Filter: st_isvalid(way) Total runtime: 30616.056 ms (4 rows)