[mapguide-internals] What MapGuide does during database schema discovery?

Gabriele Monfardini gabrimonfa at gmail.com
Thu Mar 27 02:53:59 PDT 2014


Hi all,

I would like to report some findings about this problem (first map loading
is slow since MapGuide does not proceeds until it has queried the extent of
each table and view of the feature source).

Having a look at the code of the FDO OGR provider, the "culprit" seems to
be the following line (OgrProvider.cpp, line 664, in function FdoByteArray*
OgrSpatialContextReader::GetExtent())

/*OGRErr err =*/
m_connection->GetOGRDataSource()->GetLayer(m_nIndex)->GetExtent(&e,
> TRUE);


In this line GetExtent from libgdal is called.

>From OGR documentation the second parameter is a boolean called bForce

Returns the extent (MBR) of the data in the layer. If bForce is FALSE, and
> it would be expensive to establish the extent then OGRERR_FAILURE will be
> returned indicating that the extent isn't know. If bForce is TRUE then some
> implementations will actually scan the entire layer once to compute the MBR
> of all the features in the layer.


This seems to be the case in my situation, that evaluating the extent is
expensive (and also there are a lot of tables to be investigated).

Note that it does not seem to be any check to detect an OGRERR_FAILURE.

I've tried to change the parameter with FALSE.
This change does not yield any benefit since libgdal performs the same
queries.
Moreover I'm a bit concerned that no check is performed to detect an OGR
failure, which seems to be more likely since it leaves the OGR driver the
option to return a failure if evaluating the extent is deemed to be too
expensive.

I've also made a more radical change, commenting out the call to libgdal
and returning an hard coded extent (a square POLYGON((0 0,0 50,50 50,50 0,0
0)), which is far away from real extent of my layers)

The interesting part is that apparently all works correctly inside MapGuide
(and first map loading is very quick now), so probably the extent is not
used a lot (or at least is not used in my particular workflow).

I'm not familiar with MapGuide code, may anyone point me to the code where
the extent is collected?
If this info is not used in some workflow maybe we can try to avoid to
collect it at all, since a feature source may have an unpredictable high
number of spatial relations.

For example (I used this to perform some tests) this info is collected
during FeatureService->GetSpatialContexts.

While having the Coordinate Reference System of each layer is useful (and
quick), also the extent is evaluated which is very slow.

Patching OGRProvider to return an hard coded extent speed up a lot
FeatureService->GetSpatialContexts and the returned CRS are still correct.

In my setup current collecting of extent is too slow to be acceptable, and
I'm seeking help to try to solve this problem in MapGuide code.

Any comments or help, before filing a ticket?

Regards,

Gabriele Monfardini


More information about the mapguide-internals mailing list