This project is read-only.


Topics: User Forum
Nov 21, 2006 at 11:54 PM

thanks for the great work on mssqlspatial.

I have some questions about performance. What's the best way to improve performacen. For my use case I need to draw a very detailed map (e.g. large roadlayers). What's the best way to speed up mssqlspatial (and sharpmap).


Nov 22, 2006 at 4:33 AM
If you use SharpMap with the MsSqlSpatial provider, the provider will take care of building the more performant queries for the selected extents.

Also, you could simplify big geometries for better rendering speed, this way:
// Simplify with 100 meters of tolerance.
datasource.GeometryExpression = "ST.Simplify({0}, 100)";
Where "{0}" will be replaced by the GeometryColumn property value.

Feel free to make more questions if this answer is not enough fo your needs.

Best regards,
Ricardo Stuven.
Nov 22, 2006 at 5:54 AM
You can also add a filter on the roads so you only display major roads in higher zoomlevels. Just remember to put some indexes on the columns you are filtering on.
Nov 22, 2006 at 11:04 AM
Thanks, I am going to try this out later.

Do you have any experience rendering large maps, e.g. whole europe in a "google map style".


Nov 22, 2006 at 6:17 PM
Yes, filtering according to zoom level is a good practice. But index only columns with high selectivity (rate of unique values per total amount of rows). Generally, road type has low selectivity.

Regarding large and complex layouts, "Google Maps style", ie. cached tiles, is the way to go. Check out this map, rendered by SharpMap + MsSqlSpatial.

Best regards,
Ricardo Stuven.
Dec 5, 2006 at 8:19 PM
As a side note the people that made dbspatial say on there web page that the code for mssqlspatial looks like it is slow. c# is maybe 85 percent as fast as C, although C# does make it very easy to lose track of performance with how high level and easy it is to use. Are there any spots where mssqlspatial could use optimization? Surely some blocks of code might be slow C# makes this likely with all the details it hides.
Dec 5, 2006 at 8:58 PM
Back to the old myth... Because C# is so easy to work with, it is also so much easier to create optimized code than in C+. I've seen several examples where C# code outperforms C+. I'm not saying that the C++ code couldn't be reworked to win over C#, but doing this requires a lot of work, and more risk of getting those nasty runtime errors that unmanaged code tends to have.
You must also remember that C# runs native inside SQL server - It doesn't get much better than that!
Dec 7, 2006 at 6:50 PM
Yes thats true, I guess im just saying that in general c# programmers are pretty sloppy with code. Usually because they dont need or understand how it works underneath.
Jan 19, 2007 at 3:27 PM
Ideally they shouldn't need to understand what happens underneath if the compiler, runtime, and garbage collector are doing their job.

Often times, managed apps run quicker because coding is easier and thus more simpler and concise. Of course, there are exceptions like 3d apps and other math intensive programs.