Great, thanks for following through David. Dane
On Apr 13, 2011, at 9:38 AM, David Wiesen wrote: > Never mind. I had an error elsewhere. That seems to have made a large > difference in render time. > > Thanks! > David > > On Wed, Apr 13, 2011 at 9:35 AM, David Wiesen <[email protected]> wrote: > Hi Dane, > > Thanks for the reply. I think that #1 is my problem here. I am seeing > plenty of these: > > select xmin(ext),ymin(ext),xmax(ext),ymax(ext) from (select extent(geometry) > as ext from web_plotgeometry) as tmp > > so I changed my datasource definition to be this: > > lyr.datasource = PostGIS(host='localhost', user='postgres', password='', > dbname='nextdoor', estimate_extent='false', extent='-124.454454821, > 32.3352604235004,-69.957842017, 47.688798', srid='4326', > geometry_table='web_plotgeometry', > table='(select geometry, color, 1 as > snohood from web_plotgeometry WHERE neighborhood_id=%s) as web_plotgeometry' > % hood.id) > > but I'm still seeing those extent queries. Am I missing something? > > > On Tue, Apr 12, 2011 at 5:05 PM, Dane Springmeyer <[email protected]> wrote: > Hi David: > > 1) When constructing a postgis you need to be careful to avoid triggering a > call to ST_Extent() which can be very slow. Basically you best bet is to > calculate the extent of your table once and then always pass the extent as an > option when you create the postgis datasource, eg. extent='-179,-60,179,60' > > Also, if you pass the srid and the name of the geometry table (in your case > 'web_plotgeometry') that will also allow mapnik to skip a few setup queries > and get going rendering even faster. > > 2) Have you vacuumed recently? > > 3) It appears you are requiring mapnik to re project geometries on the fly. > If you store you data in the map projection your renders will be faster. > > Dane > > > On Apr 12, 2011, at 4:50 PM, David Wiesen wrote: > >> I have been using mapnik for a while with a rather small PostGIS database. >> Recently, my database became significantly larger (currently about 8 million >> geometries), >> and I am now seeing calls to render() being very slow (20-30 seconds). >> >> I believe my database is properly indexed, and I've noticed that mapnik's >> queries run extremely quickly. For example: >> >> SELECT AsBinary("geometry",'NDR') AS geom,"color","nohood" from (select >> geometry, color, 1 as nohood from web_plotgeometry WHERE neighborhood_id=1) >> as web_plotgeometry WHERE "geometry" && SetSRID('BOX3D(-122.1830749511719 >> 37.47703779669804,-122.1817016601562 37.4781276287212)'::box3d, 4326); >> >> executes almost instantly. >> >> Furthermore, my features are not very complex, and the tiles I am generating >> don't have a lot of features on them >> (roughly dozens, usually). So I'm wondering if anyone has hints on where >> the slowdown is >> >> At a basic level, here is the relevant part of my code. >> >> Thanks for looking! >> David >> >> --------------- >> >> lyr = Layer('Neighborhood, '+init=epsg:4326') >> lyr.datasource = PostGIS(host='localhost', user='postgres', password='', >> dbname='nextdoor', >> table='(select geometry, color, 1 as snohood from >> web_plotgeometry WHERE neighborhood_id=%s) as web_plotgeometry' % hood.id) >> >> map_obj = Map(int(query['WIDTH']), int(query['HEIGHT']), '+init=epsg:3857') >> map_obj.append_style('color', self.style) # self.style is a very simple >> style with 3 rules. >> >> bbox = map(float, query['BBOX'].split(',')) >> map_obj.zoom_to_box(Envelope(*bbox)) >> >> image = Image(int(query['WIDTH']), int(query['HEIGHT'])) >> >> # SLOW >> render(map_obj, image) >> png_data = image.tostring(common.PIL_TYPE_MAPPING[query['FORMAT']]) >> return png_data >> >> >> >> >> _______________________________________________ >> Mapnik-users mailing list >> [email protected] >> https://lists.berlios.de/mailman/listinfo/mapnik-users > > >
_______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

