Prerequisites for machine learning in Db2

You must meet the following requirements to use the machine learning functionality in Db2.

  • Note: This feature is available starting from Db2 version 11.5.4.
  • OS support is limited to in the following fashion:
    • Linux x86 (Intel x86) architecture and PPCLE (Linux PowerPC Little Endian) is supported.
    • zLinux is in limited support. IDAX.LINEAR_REGRESSION, IDAX.MAE, and IDAX.MSE are not supported on zLinux.
  • The registry variable DB2_ENABLE_ML_PROCEDURES must be set to YES.
  • The Db2 database needs to have user and system temporary tablespaces with a 16K pagesize.
  • The ID that is calling the stored procedure needs to have USE privilege on the tablespaces.
  • For IDAX stored procedures, database objects are required to be storedin a regular tablespace. See below for instructions on how to create these objects.
  • The IDAX stored procedures currently do not support string_units set to CODEUNITS32.
  • The database configuration parameter string_units should be set to SYSTEM in order to be able to use IDAX stored procedures.
  • To set string_units to system, run the following command:
    db2 update db cfg for <db_alias> using string_units system
  • The database(s) must not be restrictive.
To enable machine learning functionality in an existing database:
  1. Enable the machine learning functions in the database:
    db2set DB2_ENABLE_ML_PROCEDURES=YES
  2. Update the database to enable the machine learning functionality:
    db2updv115 -a -d <database alias>

    The following is an example on how to create a 16K user and system temporary tablespace on an existing database:

    db2 "connect to <database alias>"
    db2 "create bufferpool test16k immediate size 1000 pagesize 16k"
    db2 "create system temporary tablespace tmp_tbsp pagesize 16k managed by automatic 
    storage bufferpool test16k"
    db2 "drop tablespace idax_usertempspace"
    db2 "create user temporary tablespace idax_usertempspace pagesize 16k bufferpool 
    test16k";
    db2 "grant use of tablespace idax_usertempspace to public";
    db2 "terminate"
    
  3. Create the database objects required for IDAX stored procedures in a user defined tablespace by running the following commands:
    db2 "connect to <database alias>"
    db2 "create tablespace <CUST_TAB_SPC>"
    db2 "call sysinstallobjects('IDAX', 'C', '<CUST_TAB_SPC>', null)"
    db2 "grant use of tablespace <CUST_TAB_SPC> to <public/UID>"
    where:
    • CUST_TAB_SP is the name of the custom table space that you have created.
    • public/UID defines whether the tablespace can be used by any UID or a specific UID that is calling the stored procedure.
To enable machine learning functionality in a new database:
  1. Enable the machine learning stored procedures in the Db2 database:
     db2set DB2_ENABLE_ML_PROCEDURES=YES
  2. Create a new database with a 16K user and system temporary table spaces:
    db2 "create db mydb using codeset UTF-8 territory US PAGESIZE 16384"
  3. Create the database objects required for IDAX stored procedures in a user defined tablespace, run the following commands:
    db2 "connect to <database alias>"
    db2 "create tablespace <CUST_TAB_SPC>"
    db2 "call sysinstallobjects('IDAX', 'C', '<CUST_TAB_SPC>', null)"
    db2 "grant use of tablespace <CUST_TAB_SPC> to <public/UID>"
    where:
    • CUST_TAB_SP is the name of the custom table space that you have created.
    • public/UID defines whether the tablespace can be used by any UID or a specific UID that is calling the stored procedure.
Note that for both existing and new databases, you may need to increase values for the following configuration parameters:
  • stmtheap
  • logfilsiz
  • applheapsz
  • SYSCATSPACE size