Setting the amount of memory per partition for Db2 Warehouse MPP

You can specify the amount of memory to allocate per partition, or multiple logical node (MLN), in a Db2® Warehouse massively parallel processing (MPP) configuration by editing the JSON file that is used by the service.

About this task

By default, a Db2 Warehouse service on Cloud Pak for Data:

  • Uses 24 GiB of memory per worker node, considered a minimal allocation for testing. You can change this allocation in the web console when you deploy a Db2 Warehouse service. Note that the web console unit for memory is GiB. To convert GiB to GB, multiply the GiB value by 1.048.
  • Uses 24 GiB of memory per partition (MLN). You cannot change this allocation in the web console, but you can change it by following this procedure.

When you specify a memory allocation per MLN, the database deployment process looks at the total available memory across all worker nodes and creates a number of MLNs by dividing total memory by memory-per-MLN. For example, if your configuration uses three worker nodes with a memory allocation of 64 GB per worker node, a total of 192 GB of memory is available for the configuration. If you want four MLNs for the configuration, you would edit the JSON file to specify memory-per-MLN of 48 GB.

For help with determining your memory allocation and the optimal number of partitions to create, you can use the Db2 Warehouse online configuration tool.

Note: You must make any changes to the JSON file before you deploy the database.

Procedure

  1. Locate the zen-database-core pod:
    zdc=$(oc get po | grep zen-database-core | awk {'print $1'}) 
    

    Where zdc is the name that will be returned for the zen-database-core pod. You will use this value in Step 2.

  2. Run the exec command to access an interactive shell inside of the container:
    oc exec -it ${zdc} bash 
  3. Change to the /user-home/_global_/databases directory.
  4. Run the following statements in the bash shell:
    jf=$(ls -1 /user-home/_global_/databases/ibm-db2wh-*-x86_64.json)
    python <<EOF
    import json
    jf = '$jf'
    
    with open(jf, 'r') as fd:
        parsed = json.load(fd)
    
    parsed["create"]["mem-per-mln"]=memory_per_mln
    
    with open(jf, 'w') as fd:
        json.dump(parsed, fd, indent=2)
    EOF

    Where memory_per_mln is the amount of memory that you want to allocate to each MLN.

    The statements will update the ibm-db2wh-version-x86_64.json file to set the default memory allocation per node.