Hello everyone. In case that on the way to the select something went wront, here are the steps i used to populate my database: 1) I downloaded the germany-latest.osm from geofabrik and used osmfilter on it, to reduce the amount of data. Because less data can't be bad, right? The used command is:
2) I importet the data into a default installation of postgrsql + postgis with cygwin. The used command, which didn't show any errors is:
Now i have, as far as i can tell by looking into it with pgAdmin, a database with all the data i want to use. But accessing those data is terrible slow and i have no idea why. Is it that I'm not using an ssd? Is something wrong with my SQL command? Either way, it takes 48-50s to get data, no matter how often i've executed it before. Shouldn't some form of caching kick in when i fire the same request repeadetly? On the good side, after a bit of playing around the data aquired by that sql command seems to be correct :-).
What I'm trying to get is "everything within 500m of coordinate" and i would like to get this kinda faster than those 48-50s... especially since theres going to be more than 1 concurrent request at a time. asked 15 Nov '15, 20:57 EinFreierNick |
PostGIS will normally use spatial indexes to speed up these types of queries. These indexes have been created by osm2pgsql but your query is formulated in a way that renders them ineffective. Hence PostGIS must actually compute the difference between your point and every single polygon in the database. Your database is in Mercator metres since you haven't specified "-l" on import. Therefore, do
to utilize the index. If you are worried about the discrepancy between Mercator metres and real metres, you can still use a more precise calculation based on ST_DWITHIN or ST_DISTANCE with geography data types, but only after you have filtered out the candidate objects with the index - i.e. you might use a distance of 1000 in the query above, and then add your WHERE condition at the end. Use the answered 15 Nov '15, 22:26 Frederik Ramm ♦ executing that commands give me the following error message: ERROR: Operation on mixed SRID geometries * Error * ERROR: Operation on mixed SRID geometries SQL state: XX000
(16 Nov '15, 16:50)
EinFreierNick
if i switch positions for 4326 and 3857, the query executes - but delivers no results no matter how high i set the meteres
(16 Nov '15, 17:45)
EinFreierNick
You might have imported your database in 900913 not 3857 - try switching 3857 in my example to 900913. Both are equal but PostGIS doesn't know.
(16 Nov '15, 19:02)
Frederik Ramm ♦
Ah :) This works. Execution time for the first execution was 72ms. Every execution afterwards was 23-25ms. That is a time that allows me to go further :) THANK YOU.
(16 Nov '15, 20:05)
EinFreierNick
|
You could likely skip the "osmfilter" step by writing a good style file for the osm2pgsql import.