Optimizing document types

In the internal ImageMaster database model, attributes of one document type can be distributed to different database tables. This used to happen until ImageMaster 9.11.2, if further attributes were added to an existing document type e.g. by adding these via the AdminClient. An optimization merges the internal database tables in order to have all document types managed by one database table again (to gain better performance by a simplification of the data model complexity). Since ImageMaster 9.12.1, adding a new single-valued attribute will no longer create new database tables so the optimizing step now becomes obsolete in this use case. However, for upgrading from older ImageMaster releases the optimizing step can still be useful.

The command “optimizeDocTypes” generates a script to optimize the database table structure of one or more ImageMaster document types. The command takes as arguments a list of document type names to optimize. If no names are provided, the command will output a list of document types with potential for optimization.

The generated script includes commands to copy existing attribute values into the merged database table. This process takes a long time if a large set of documents is to be transformed. It is recommended carrying out the optimization as a regular maintenance task ideally always after adding a new document type (when the newly added attribute is still empty).

Optimization procedure with example execution calls

To optimize document types with the upgrade tool (ima-db-tool) follow these steps, where steps 2 and 3 must be executed for each document type from the list of step 1:

  1. Get the list of document types that can be optimized:

    java -jar <path to ima-db-tool.jar> -s <JDBC URL to database> -u <username> -p <password> -d <path to JDBC driver jar> optimizeDocTypes

For each document type from the above list, use this in the command below as {docType} , and do the following:

  1. Generate the SQL script (in this example “optimize.sql”) for document type optimization for this document type:

    java -jar <path to ima-db-tool.jar> -s <JDBC URL to database> -u <username> -p <password> -d <path to JDBC driver jar> optimizeDocTypes {docType} > optimize.sql

  2. Execute this generated SQL script. Below is an example of a script execution with PostgreSQL:

    psql <databasename> <databaseuser> -f optimize.sql

Examples for PostgreSQL

Once get the list of document types:

java -jar ima-db-tool-9.12.2-1-jar-with-dependencies.jar -s jdbc:postgresql://localhost:5432/ima -u postgres -p postgres

-d postgresql-xx.x.xx.jar optimizeDocTypes

 

Candidates for document type optimization:

 myDocumentType1

 myDocumentType2

For each document type do the following (illustrated with “myDocumentType1” here):

  • generate the SQL script (for one document type optimization):

java -jar ima-db-tool-9.12.2-1-jar-with-dependencies.jar -s jdbc:postgresql://localhost:5432/ima -u postgres -p postgres

-d postgresql-xx.x.xx.jar optimizeDocTypes myDocumentType1 > optimize.sql

  • execute the above SQL script (in this example with database name “imadb” and database user “imauser”):

# psql imadb imauser -f optimize.sql