Faster, faster, faster! Use large memory pools to boost your SQL performance.
More companies are creating and running queries to help their business leaders make better decisions, ones that are based on data facts instead of educated guesses. As users see the business value provided by these reports, it's only a matter of time before they'll ask for the reports to run faster.
The slowest part of any query execution is the time that it takes for the data to be read from disk to main memory. When data being analyzed is already resident in memory, the query can run substantially faster. This advantage is one of the reasons that the interest in in-memory database products has increased in recent years. This performance benefit, along with advancements in 64-bit processors that enable large memory stores, make it possible for you to have most, if not all, of your database objects resident in memory. For instance, some IBM Power Systems servers support a maximum memory size of 8 terabytes!
Based on the fact that IBM Power Systems support large memory pools, it should be no surprise that the DB2 for i SQL engine has technology that provides capabilities similar to an in-memory database. This capability is activated with the KEEPINMEM (Keep In Memory) parameter on the Change Physical File (CHGPF) and Change Logical File (CHGLF) system commands. The KEEPINMEM parameter was delivered with the IBM i 7.1 release.
Activating the in-memory enablement capability with the KEEPINMEM parameter is supported for DB2 objects created with SQL and DDS. However, DB2 for i will only honor this setting when these DB2 objects are accessed using SQL statements. As a result, the KEEPINMEM support will not improve the performance of data access requests submitted through the native record-level access, Open Query File (OPNQRYF), or Query/400 interfaces.
As the following command invocations demonstrate, usage of the KEEPINMEM parameter is straightforward.
CHGPF FILE(mylib/mytable) KEEPINMEM(*YES)
CHGLF FILE(mylib/mysqlix) KEEPINMEM(*YES)
Execution of these Change commands does not load the specified DB2 object into main memory. When an SQL statement references a DB2 object with a value of *YES specified for KEEPINMEM, the SQL Query Engine (SQE) will request that the DB2 object be brought into memory at that time. This request to pre-bring the DB2 object into memory runs asynchronously. The asynchronous implementation enables the execution of the SQL statement to continue while the pages for the DB2 object are being loaded into memory.
In addition, the pre-bring memory function used by the in-memory enablement feature utilizes parallel I/O techniques to help the specified DB2 object be brought into memory faster than other system commands, such as the Set Object Access (SETOBJACC) command, which are limited to using a single thread.
Like the SETOBJACC command, the in-memory enablement feature does not guarantee that the all pages for the specified DB2 object will remain in memory. However, given the fact that every SQL statement that references the DB2 object will request the object to be loaded into memory, there's a very high probability that the pages for the DB2 object will remain in memory, especially if the MEMORY_POOL_PREFERENCE QAQQINI option is used in conjunction with the KEEPINMEM support to specify that SQE load the DB2 objects into a private memory pool. By default, the DB2 objects with the KEEPINMEM option are brought into the memory pool used by the job running the SQL statement. The possible values for the MEMORY_POOL_PREFERENCE QAQQINI option are the number of the memory pool, *BASE, or *JOB. The management of these in-memory DB2 objects works most efficiently when the memory pool paging option is set to the value of *CALC.
Specifying a value of *YES for the KEEPINMEM parameter for a DB2 object does not change how frequently the changed data pages for that object are written to disk. The IBM i operating system will continue to manage these changed data pages in the same manner as other objects on the system.
Now that you're aware of the IBM i 7.1 support that makes it easy to keep popular DB2 tables, indexes, physical files, and keyed logical files resident in memory, you need to decide how many DB2 objects should have a value of *YES for the KEEPINMEM parameter. That number of objects will obviously depend on the amount of main memory available, the size of the DB2 objects, and the way your SQL applications access the objects.
While this analysis might take some work, the good news is that you have an easy way to use large memory pools to boost your SQL performance.
as/400, os/400, iseries, system i, i5/os, ibm i, power systems, 6.1, 7.1, V7, V6R1