Increasing OgrLayer performance

Help me figure out how to improve the performance of OgrLayer. I load a layer from PostgreSQL with polygons and create enough categories (150) to visually display different objects by color. After creating categories, the map performance drops quite a bit. Redraw Time increases to 300 ms. However, it works exactly the same if you open ShapeFile locally from disk.there is no such performance drop. I found a my Layer file next to the MyLayer.mwd. If you delete it, the performance also drops and Redraw Time increases to 300 ms. If it is returned to its place, the Redraw Time becomes ~ 90-100 ms. My question is: how do I repeat the performance increase already on OgrLayer from SQL. What kind of file is MyLayer.mwd?

Hello Valeriy.

I’m not sure I fully understand the difference between your two scenarios, but I will make some comments.

  1. The mdw is a spatial index file, so it makes sense that performance is better when the spatial index is present.
  2. Adding categories to a Shapefile, whether it came from OGR or from a file, should result in the same behavior.
  3. Perhaps your disk-based Shapefile has the Spatial Index, but your in-memory Shapefile (created from OgrLayer.GetBuffer()) does not have the spatial index. You could try calling Shapefile.CreateSpatialIndex after calling GetBuffer, and see if that makes a difference.

Regards,
Jerry.

Hello Jerry.

I’m not getting it right. It is not clear what to specify in the ShapeFileName parameter. Name the as such a have OgrLayer there is no. I tried to specify the name of the layer on the table from the SQL server, but in the root folder of the program, two files are created with the given name up to 3 characters. And all. The index doesn’t work. No performance improvement.