[postgis-users] Re: [mapserver-users] SDE performance

Jan Hartmann jhart at frw.uva.nl
Mon Nov 25 03:03:55 PST 2002


chodgson at refractions.net wrote:

> 
> I'm not familiar with the mapserver code, but I didn't see anything about where 
> to store the actual connection identifiers. Don't we need another array, which 
> is set to zero until the connection is opened, then set to the connection 
> identifier after it has been opened (so that all the connections can use it) 
> and then used in the final closing function to close the connection?


Right!. You need a third array with pointers to opened connections. This 
array cannot be declared globally (at least not in a simple way). 
Connections can be PostGIS, Oracle and  SDE, and those are very 
different beasts. This array has to be declared statically by each 
database program (for PostGIS in mappostgis.c). Each time a new 
connection is opened, a pointer to this connection will be stored in the 
array. This pointer can eventually be used by the close function.

So in this scenario you need the following arrays: an array with 
connections strings, an array with close functions, and arrays with 
pointers to connections for respectively PostGIS, Oracle and SDE. The 
first two are part of the global MAP object, and are visible everywhere, 
the last three are declared statically within the program files for 
PostGIS, Oracle and SDE.  As an example, take a MapFile with 10 
connections, 5 to PostGIS, 3 to SDE and 2 to Oracle. The string array 
would be:

PPSPPOPSSO

The array with close functions would be:

P-S--O----

And the static arrays for the PostGIS, SDE and Oracle connection pointers:

P---------
--S-------
-----O----

Note that you can also have several different connections to PostGIS; 
they would just require their own close functions and connections 
pointers. Note also that all information about a connections (string, 
close function and connection pointer) is available at the same index 
number of the different arrays. That way you don't need hashes. The 
close function and connection pointer are put in their place by the the 
opening functions of the database programs, which is passed the index 
number of this connection. The close function is called at the end and 
is also passed this index number. Of course only the first connection of 
several identical ones has to execute a close function.

As I said, this way the database specific code is separated from the 
global control flow. The only thing the global program has to do is:

- add the string and functions array
- pass the index number of each new connection to the database programs
- execute the not-NULL closing functions

Internally, mappostgis.c could leave everything as it was (closing 
connections on a per-layer basis). Only if it sets a pointer to a 
closing function in the global close array, the global program will 
execute this at the end. This way the programmatic changes to PostGIS, 
SDE and Oracle don't have to be synchronized and can be done at their 
own time.

Sorry to be so long, but I couldn't make things clear in shorter terms. 
If you can see your way with this  I'll put the matter to Steve.

Jan




More information about the postgis-users mailing list