[Geoserver-devel] [jira] (GEOS-5151) getTables called multiple times in wfs request using sqlview

Robert Marianski created ImprovementGEOS-5151
getTables called multiple times in wfs request using sqlview

Issue Type:

ImprovementImprovement

Assignee:

Andrea Aime

Components:

WFS

Created:

08/Jun/12 5:39 PM

Description:

I’m making a wfs request against a geoserver sql view (not a database view) and to generate the response multiple calls are made to retrieve the list of tables from the database. The datastore is oracle in my case, and getting the list of tables is prohibitively slow. Calling it multiple times only exacerbates the issue.

I’ve traced through the request, and 3 calls are made during the course of serving up the wfs request. I was using the 2.5 suite version of geoserver. Here’s a rough outline of what’s happening.

All the getTables calls are made from the geotools JDBCDataStore::createTypeNames call. But, they all follow a slightly different path to get there. All 3 start from ResourcePool::getFeatureSource. First a check is made to see if the dataStore is a JDBC store and there is a virtual table. If so, then the virtual table is added. This is how the first getTables call gets triggered.
https://github.com/opengeo/geoserver/blob/ec5e24578288c9eaf673fd72e766fa58c61fbb03/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java#L840

Then further down, ResourcePool::getFeatureType is called. Note that false is passed for the second parameter, the handleProjectionPolicy.
https://github.com/opengeo/geoserver/blob/ec5e24578288c9eaf673fd72e766fa58c61fbb03/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java#L849

This method in turn is responsible for the next two calls. The implementation first checks if it is cacheable, which in this case it is not because false is passed in for handleProjectionPolicy. The code then leads to a call to generate the list of type names to find a unique virtual table name. This results in the 2nd getTables call.
https://github.com/opengeo/geoserver/blob/ec5e24578288c9eaf673fd72e766fa58c61fbb03/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java#L626

And finally, the virtual table is added right after, which leads to the 3rd getTables call.
https://github.com/opengeo/geoserver/blob/ec5e24578288c9eaf673fd72e766fa58c61fbb03/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java#L632

I would prefer if getTables wouldn’t be called at all to generate the response. Can the type names be cached? I understand that means as a consequence geoserver will need to be restarted if a new table or view is added to the database, but maybe this could be handled as a configurable policy. And even if it was being cached, perhaps we could provide a way to invalidate it in a live geoserver environment. I’m certainly open to any ideas here.

In case it helps, here are the relevant bits of the stack traces for the 3 cases.

JDBCDataStore.createTypeNames() line: 842
JDBCDataStore(ContentDataStore).entry(Name) line: 554
JDBCDataStore(ContentDataStore).ensureEntry(Name) line: 585
JDBCDataStore(ContentDataStore).getFeatureSource(Name, Transaction) line: 383
JDBCDataStore(ContentDataStore).getFeatureSource(String) line: 350
JDBCDataStore(ContentDataStore).getSchema(String) line: 335
JDBCDataStore.addVirtualTable(VirtualTable) line: 284
ResourcePool.getFeatureSource(FeatureTypeInfo, Hints) line: 840

JDBCDataStore.createTypeNames() line: 842
JDBCDataStore(ContentDataStore).getTypeNames() line: 299
ResourcePool.getFeatureType(FeatureTypeInfo, boolean) line: 626
ResourcePool.getFeatureSource(FeatureTypeInfo, Hints) line: 849

JDBCDataStore.createTypeNames() line: 842
JDBCDataStore(ContentDataStore).entry(Name) line: 554
JDBCDataStore(ContentDataStore).ensureEntry(Name) line: 585
JDBCDataStore(ContentDataStore).getFeatureSource(Name, Transaction) line: 383
JDBCDataStore(ContentDataStore).getFeatureSource(String) line: 350
JDBCDataStore(ContentDataStore).getSchema(String) line: 335
JDBCDataStore.addVirtualTable(VirtualTable) line: 284
ResourcePool.getFeatureType(FeatureTypeInfo, boolean) line: 632
ResourcePool.getFeatureSource(FeatureTypeInfo, Hints) line: 849

Project:

GeoServer

Priority:

MajorMajor

Reporter:

Robert Marianski

This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your [JIRA administrators](https://jira.codehaus.org/secure/ContactAdministrators!default.jspa). For more information on JIRA, see: [http://www.atlassian.com/software/jira](http://www.atlassian.com/software/jira)