Recompiling a query after configuration changes

To observe the effect of configuration changes that affect query optimization, it might be necessary to cause the query optimizer to recompile the statements that are cached.

Procedure

You can cause the query optimizer to recompile a statement by performing any of the following actions:

  • Invalidating the cached dynamic statements for specific tables using the RUNSTATS command:
    RUNSTATS ON TABLE <tableschema>.<tablename> 
       WITH DISTRIBUTION AND SAMPLED DETAILED INDEXES ALL
    Note: This will refresh the table statistics and subsequent query compilations will use the new statistics as well as the new configuration settings.
  • Removing all cached dynamic SQL statements currently in the package cache:
    FLUSH PACKAGE CACHE DYNAMIC