Hi,
We’re evaluating ThinkGeo 8.0.0.0 WebEdition with MsSql2008FeatureLayer to render images from SQL SERVER database. We are tracing the database queries sent to the server and we found that ThinkGeo performs some queries for each requested image. Those queries seems like are performed in order to get metadata about the geometry type and index name. The queries that we are talking about are:
SELECT allTypes.name
FROM sys.columns allColumns, sys.types allTypes, sys.all_views allViews
WHERE allColumns.object_id=allViews.object_id AND allColumns.user_type_id=allTypes.user_type_id AND allTypes.system_type_id=240 AND allViews.name=’[table_name]’ union SELECT allTypes.name FROM sys.columns allColumns, sys.tables allTables, sys.types allTypes WHERE allColumns.object_id=allTables.object_id AND allColumns.user_type_id=allTypes.user_type_id AND allTypes.system_type_id=240 AND allTables.name=’[table_name]’
go
SELECT allTables.name from sys.spatial_index_tessellations, sys.tables allTables where allTables.name=’[table_name]’ AND allTables.object_id=sys.spatial_index_tessellations.object_id
go
SELECT sys.indexes.name from sys.indexes, sys.tables allTables where allTables.name=’[table_name]’ AND allTables.object_id=sys.indexes.object_id AND sys.indexes.type_desc=‘SPATIAL’
go
We want to avoid those queries because this metadata is static. We can allow those queries to be performed for the first image requested and thereafter avoid all of them or, define those values explicitly when we are creating the Layer. The first option requires code change and ThinkGeo does not allows the second option because property SpatialDataType is readonly and there’s is no property to set the index name.
Can we achieve it with inheritance from MsSql2008FeatureLayer and MsSql2008FeatureSource without major effort?
Regards,
BdaF
Frequently metadata queries
Hi BdaF,
I think it’s not easy to override these classes, but avoid frequently open the MsSql2008FeatureLayer should avoid that.
Let me do more detail description for the 3 requests:
The 1st request only be called on Open function, so make sure you open currently MsSql2008FeatureLayer only once can avoid duplication requests.
For the 2nd request, it’s for make sure whether the Index file exist. It will be called in Open function also, but it looks if you get the index succeed, it won’t be excuted again, and if you don’t set SpatialIndexName it won’t be executed also.
The 3rd request will be called on Open also, and it will be called if you call BuildIndex with ReBuild mode.
Wish it’s helpful.
Regards,
Don
Hi Don,
We’re using LayerOverlay to draw images from HTTP client requests (browser is the client).
It looks like the drawing of the images are being made by the internal code of the handler tile_GeoResource.axd. Somewhere on the process of handling HTTP request from client by that handler, there should be some call to the Open() method that causes those kind of metadata queries to be sent to the database server. Because of this, the solution that you suggested of keeping the Layer open between requests cannot be achieved by us because that call is being made by ThinkGeo internal code.
We realized that those metadata queries are being called for each one of the requested images from the client (browser). We configured LayerOverly.TileType = TileType.MultipleTile to made several concurrent request for images and for each one of the requested images, those metadata queries will be executed on the database (we’re profiling database queries) that translates to a massive amount of queries to get static data (on our case is static because we’re not thinking of changing at any time future).
Can we suppress those queries in anyway or can we override something on the ThinkGeo classes to avoid it?
Best regards,
BdaF
Hi BdaF,
Please try this workaround and let me know whether that works for you.
Inherit from MsSql2008FeatureLayer then override CloseCore function like this:
protected override void CloseCore()
{
//base.CloseCore();
}
That will prevent to close FeatureSource and you can build another function to force close when you need.
Please let me know whether that works for you.
Regards,
Don
Hi Don,
We’ve tried the proposed solution without success.
We will likely implement our custom SQL SERVER FeatureSource and FeatureLayer.
Thanks,
BdaF
Hi BdaF,
In my test, if I implement this, the Open Function of MsSql2008FeatureSource only be fired once (MsSql2008FeatureLayer in LayerOverlay). So I think that should works for you.
And in fact, my workaround is also implement your custom FeatureSource and FeatureLayer, if you prevent close layer, close feature source is also be stopped.
So could you please double check whether the MsSql2008FeatureLayer keep sent the 3 queries after you implemented the custom feature layer which prevent close function? I want to make sure that because in my test result it looks works.
Regards,
Don
Hi Don,
We’ve detected that the newer versions of ThinkGeo 8.0.0.0 allow explicit definition of the spatial index name and geometry type. If we set values on properties SpatialDataType and SpatialIndexName , the aforementioned queries are not executed.
Problem solved.
Thanks,
BdaF
Hi BdaF,
I am glad to hear our latest version have solution for it.
Any question please let us know.
Regards,
Don