drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
692 stars 90 forks source link

[!"building"] results in out-of-memory error #666

Closed Hufkratzer closed 2 years ago

Hufkratzer commented 2 years ago

If I run this quite simple looking query for a not very large area

[out:json][timeout:100][bbox:50,7,51,8];
(
  area
  ["leisure"="sports_centre"]
  ["sport"="tennis"]
  [!"building"]
  ;
);
out body;
>;
out skel qt;

I get an

runtime error: Query run out of memory using about 2048 MB of RAM.

But if I run (for the same area) the more complex query

[out:json][timeout:100][bbox:50,7,51,8];
(
  area
  ["leisure"="sports_centre"]
  ["sport"="tennis"]
//  [!"building"]
  ;
  - area
  ["leisure"="sports_centre"]
  ["sport"="tennis"]
  ["building"]
  ;
);
out body;
>;
out skel qt;

I get the desired result (it just takes a bit long).

Maybe this can be improved so that the simpler query works too, and possibly even faster than the complex one.

mmd-osm commented 2 years ago

I would rewrite your first query as follows to force another execution sequence. I'm not sure why you want to query for "area", you probably want ways and relations, right?

[out:json][timeout:100][bbox:50,7,51,8];
wr
  ["leisure"="sports_centre"]
  ["sport"="tennis"];
wr._[!building];

out body;
>;
out skel qt;

NB: This workaround depends on your Overpass release, and may not be needed on every version: issue666

Hufkratzer commented 2 years ago

I would rewrite your first query as follows to force another execution sequence.

Thanks for the hint, I just didn't know this trick.

I'm not sure why you want to query for "area", you probably want ways and relations, right?

Unclosed ways are not interesting in this case, therefore I thought I should better use area. Maybe it was a bad idea. Is it wrong to use area here?

[out:json][timeout:100][bbox:50,7,51,8];
wr
  ["leisure"="sports_centre"]
  ["sport"="tennis"];
wr._[!building];

out body;
>;
out skel qt;

NB: This workaround depends on your Overpass release, and may not be needed on every version: issue666

I now tried it with

(via https://overpass-turbo.eu/)

and with both I get the out-of-memory error. Is there a publicly available server where it works without the workaround?

mmd-osm commented 2 years ago

s it wrong to use area here?

area is pretty much Overpass API specific, and bounding box filtering is not supported for areas, which are based on relations. That's why I thought you probably want to use ways and relations instead.

Is there a publicly available server where it works without the workaround?

Nope, I'm afraid, not at this time.

drolbr commented 2 years ago

Fixed in bb9ccb2dede0af6da07b9dcbb68f7e92041abfdf

Gets live once 0.7.58.1 is live.

mmd-osm commented 2 years ago

I guess this was fixed in https://github.com/drolbr/Overpass-API/commit/0d5d0d39ccffba658062164f99711e3f2620ad2a, as the example in this issue didn't use attic data.

drolbr commented 2 years ago

I guess this was fixed in 0d5d0d3, as the example in this issue didn't use attic data.

Well, when there is a known bug, then it makes sense to fix all straightforward further variants of that bug.

mmd-osm commented 2 years ago

It was more of a question, as you've mentioned https://github.com/drolbr/Overpass-API/commit/bb9ccb2dede0af6da07b9dcbb68f7e92041abfdf, and it wasn't immediately clear how this fixes this particular issue. Fixing further issues makes sense, of course.