Sharing Database Connections

If you have elected to store multiple datastores, region databases, and a cross-region database in a single physical database, you can configure these resources to share one database connection, which can significantly reduce the load on database server side resources, such as session management and memory usage. You can take advantage of this with both the ODBC data source and the connection string methods.

For ODBC connections:

  • Create an ODBC data source for the single physical database.
  • Reference the data source using the dbfhconfig -add/-update -odbcdsn actions/option; for example, you can update existing configurations as such:
    dbfhconfig -update -server:ONEDB_SS -dsn:SS.ONEDS -odbcdsn:ONEDB_SS
Note: Each entry you specify must belong to the same -server group within the configuration file, and each -dsn must be configured to use the same credentials to access the database.

The following example shows an excerpt from an MSSQL database configuration file where two datastores (SS.DATASTORE1 and SS.DATASTORE2), a region database (SS.REGION), and a cross-region (SS.CROSSREGION) all use one database connection (the ONEDB_SS data source).

...
<server name="SERVER_SS" type="sqlserver" access="odbc">
    <dsn name="SS.MASTER" type="database" dbname="master"/>
    <dsn name="SS.CROSSREGION" type="crossregion.cas" dbname="onedb_ss" odbcdsn="ONEDB_SS" />
    <dsn name="SS.REGION" type="region.cas" region="MYREGION" dbname="onedb_ss" odbcdsn="ONEDB_SS" /><dsn name="SS.DATASTORE1" type="datastore" dsname="MYFILES1" dbname="onedb_ss" odbcdsn="ONEDB_SS" />
    <dsn name="SS.DATASTORE2" type="datastore" dsname="MYFILES2" dbname="onedb_ss" odbcdsn="ONEDB_SS" />
  </server>
...

For connection string connections:

Ensure that the connection string specifies the single physical database:
dbfhconfig -update -server:ONEDB_SS -dsn:SS.ONEDS -connect:"Driver={PostgreSQL ANSI};Server=localhost;Port=5432;Database=onedb_pg;Uid=myuser;Pwd=mypass;"
Note: Each entry you specify must belong to the same -server group within the configuration file, and each connection string must be configured to use the same credentials to access the database, effectively reusing the same connection string for each required entry within the -server group.

The following example shows an excerpt from a PostgreSQL database configuration file where the datastores (PG.DATASTORE1 and PG.DATASTORE2), a region database (PG.REGION), and a cross-region (PG.CROSSREGION) all use one database connection, as evidenced by the same connection string for each entry.

...
<server name="SERVER_PG" type="postgresql" access="odbc">
    <dsn name="PG.POSTGRES" type="database" dbname="postgres" connect="Driver={PostgreSQL ANSI};Server=localhost;Port=5432;Database=postgres;Uid=myuser;Pwd=mypass;" />
<dsn name="PG.CROSSREGION" type="crossregion.cas" dbname="onedb_pg" connect="Driver={PostgreSQL ANSI};Server=localhost;Port=5432;Database=onedb_pg;Uid=myuser;Pwd=mypass;" />
    <dsn name="PG.REGION" type="region.cas" region="MYREGION" dbname="onedb_pg" connect="Driver={PostgreSQL ANSI};Server=localhost;Port=5432;Database=onedb_pg;Uid=myuser;Pwd=mypass;" /><dsn name="PG.DATASTORE1" type="datastore" dsname="MYFILES1" dbname="onedb_pg" connect="Driver={PostgreSQL ANSI};Server=localhost;Port=5432;Database=onedb_pg;Uid=myuser;Pwd=mypass;" />
    <dsn name="PG.DATASTORE2" type="datastore" dsname="MYFILES2" dbname="onedb_pg" connect="Driver={PostgreSQL ANSI};Server=localhost;Port=5432;Database=onedb_pg;Uid=myuser;Pwd=mypass;" />
  </server>
...