Top
Symfoware Server V12.1.0 Application Development Guide
FUJITSU Software

2.4.2 Statement Caching Feature

The statement caching feature caches SQL statements for each individual connection. This means that when an SQL statement with an identical string is next executed, the analysis and creation of the statement can be skipped. This improves performance in cases such as when an SQL statement with an identical string is executed within a loop or method that is executed repeatedly. Furthermore, the statement caching feature can be combined with the connection pooling feature to further enhance performance.

The mechanism used by the statement caching feature is described below:

Cache registration controls

You can configure whether to cache SQL statements using the setPoolable(boolean) method of the PreparedStatement class when the statement caching feature is enabled.

Values that can be configured are shown below:

false

SQL statements will not be cached, even when the statement caching feature is enabled.

true

SQL statements will be cached if the statement caching feature is enabled.

Number of caches

Specify the number of SQL statements with different strings per connection.

Note

  • The specified values may become unsuitable when changes are made to the application, so periodically execute pg_stat_statement to check and update to suitable values if required.

  • Cached SQL statement information will consume a certain amount of memory, so consideration must be given to the upper limit for memory consumption. A guide to estimating the memory consumed by the statement caching feature is shown below:

    • Client

      connsPerAppProc x numOfCaches x 2 KB (*1)
    • Server

      maxConnsPerAppProc x numOfCaches x 10 KB (*1)

      *1: Approximate memory consumption per SQL statement