ThinkGeo.com    |     Documentation    |     Premium Support

Map refreshes very slow

Hi,


When I have a PostgreSqlFeatureLayer, the PostgreSQL database is on my local machine, there are about 40,000 point symbols in this layer. When I add on this layer, the map refreshes very slow, if I do a track zoom-in, it became blur immediately, then took 25 seconds to display properly; if I click on a zoom-out or zoom- in button, it took 24 seconds to finish. It is also very slow to pan around the map.


Tried to export the data into an ESRI shape file, it took about 4 seconds to do the same jobs.


Is this normal or am I doing sth wrong? In our scenario, there could be more then tens of millions of data in the database. How to speed up?

 



Rose



Rose,  
  
 Did you create the index for your Postgre database? Please try the following query to generate the index. (replace the tablename and GeometryColumnName with your corresponding ones) 
  
  create index tablename_sidx on tablename using gist (GeometryColumnName) 
  
 Thanks, 
  
 Ben

Ben:


I did create the index for my Postgre database,  actually I have more than 400,000 records in the database, the query I used to create the index is:


create index indexname on tablename using btree (GeometryColumnName).


But I tried your query, the map still refreshes very slow, no difference.


Any advice?


Rose



When the data is loaded, it is very slow to zoon in/out, or pan. 
 Is this a performance issue? 
  
 Rose

Rose, 
  I am not very sure what the extent you are using for the spatial query, and how many records will be returned. It takes me 11.93 seconds to get all the 194,261 records from my postgre. Please try the following SQL statement to test the performance: SELECT AsBinary(“GeometryColumnName”) FROM TableName WHERE GeomFromText(‘WKT’, SridNumber) && “GeometryColumnName”; 
         You need to replace “GeometryColumnName”, “TableName”, “WKT” and “SridNumber” with your corresponding ones. The “GeometryColumnName” is the shape column in your table, “WKT” is the well known text to show the current extent, so you can use Map.CurrentExtent.GetWellKnownText() to replace it, “SridNumber” is the EPSG number, for example: 0 for null, 4326 for DecimalDegree or 900913 for GoogleMap. 
   The SQL statement is for a spatial query, getting shapes in binary by the specified extent. I think this statement can tell whether it’s a postgre server’s problem or PostgreExtension’s problem. If the speed here is also very slow, then it must be some problems with the server. 
  
 Thanks, 
  
 Ben 


Ben: 
  
 I have 736,306 records in my database, it took me about 50 seconds to get all of them displayed, my extent is the whole UK area. 
  
 I tried the SQL statement you mentioned above in pgAdmin, it took 2.980 second to retrieve all the data. 
 Unfortunately I can not try the SQL statement in my application, the new Postgre extension I got from following link has a problem. 
 gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5299/afv/topic/Default.aspx 
  
 Thanks 
  
 Rose

Rose,


Please get the latest PostGreExtension from the following post and try the SQL statement within  ExecuteSqlQuery to compare the speed difference. If it's slower, could you double check some other aspects like network speed which might affect the result?


gis.thinkgeo.com/Support/Dis....aspx#7800


Thanks,


Ben


 


 



Ben:


The SQL statement: SELECT AsBinary("GeometryColumnName") FROM TableName WHERE GeomFromText('WKT', SridNumber) && "GeometryColumnName"; 

 


It does not work in both PostgreExtensions, it complains "Can not find the geometry column in table : 'vesselsview'".


I tried this statement: SELECT * FROM TableName WHERE GeomFromText('WKT', SridNumber) && "GeometryColumnName";  it works. With 736,306 records in my table, it took 46 seconds instead of 50 seconds with the new PostGreExtension. My database is installed on the developer's machine, same machine with the application, so no network speed issue.

 


Once the data is displayed on the map, it took 26 seconds to zoom in/out. Is this normal?


Thanks


Rose



Rose, 


I made a performance test in which I get all the records within one rectangle and draw them out, here is the result.
 
Records within the rectangle    Drawing Time(s)
Rectangle 1         40,000                                    1.5
Rectangle 2         72,943                                    2.6              
Rectangle 3         163,000                                  5.7
Rectangle 4         194,261                                  6.1
                       
The Postgre server is running on the same machine. The Drawing Time includes pulling data from database and rendering them out.
                        
As there is linear relationship between Records Count and Drawing Time, we can say if the specific extent contains 736.306 records, the drawing time will be around 25 seconds. Now just wonder how many records you want to display at a time in your case? If there are a lot of records, 26 seconds makes sense (although that doesn’t make much sense to display too many records at a time); if the records are fewer, the time should be reduced linearly.
 
Thanks,
 
Ben