Re: Slow query: Select all buildings that have >1 pharmacies and >1 schools within 1000m
В списке pgsql-performance по дате отправления:
| От | Tomas Vondra |
|---|---|
| Тема | Re: Slow query: Select all buildings that have >1 pharmacies and >1 schools within 1000m |
| Дата | |
| Msg-id | 1e50929e6ba44cabb8deb2ad0ee98c82.squirrel@sq.gransy.com обсуждение исходный текст |
| Ответ на | Slow query: Select all buildings that have >1 pharmacies and >1 schools within 1000m (Stefan Keller <sfkeller@gmail.com>) |
| Ответы |
Re: Slow query: Select all buildings that have >1
pharmacies and >1 schools within 1000m
|
| Список | pgsql-performance |
On 7 Srpen 2012, 14:01, Stefan Keller wrote:
> Hi
>
> I have an interesting query to be optimized related to this one [1].
>
> The query definition is: Select all buildings that have more than 1
> pharmacies and more than 1 schools within a radius of 1000m.
>
> The problem is that I think that this query is inherently O(n^2). In
> fact the solution I propose below takes forever...
What about plain INTERSECT? Something like
SELECT osm_id FROM osm_poi AS p, osm_polygon b
WHERE p.tags @> hstore('amenity','pharmacy')
AND ST_DWithin(b.way,p.way,1000)
INTERSECT
SELECT osm_id FROM osm_poi AS p, osm_polygon b
WHERE p.tags @> hstore('amenity','school')
AND ST_DWithin(b.way,p.way,1000)
Or something like that. But maybe it's a complete nonsense ...
Tomas
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера