SQLCache

Description

Specifies the number of SQL statements PocketBuilder should cache. The default is 0, specifying an empty SQL cache.

PocketBuilder caches:

Applies to

Syntax

The syntax for setting SQLCache depends on the database interface you are using.

Use the following syntax to set the SQLCache parameter:

SQLCache = value

Parameter

Description

value

The number of cursors you want to open in a script, plus the number of DataWindow-generated SELECT statements with retrieval arguments (default = 0).

Default

SQLCache = 0

Usage

Maintaining statements in the cache Statements in the SQL cache are maintained on a least-recently-used (LRU) basis. In other words, if a statement must be removed from the cache to make room for another statement, PocketBuilder removes the statement that was least recently executed.

SQLCache and bind variables Caching SQL statements that you frequently execute improves their performance. Statements with bind variables are generally the most frequently used. In fact, if your DBMS does not support bind variables, caching statements is of limited value.

Setting DisableBind to use cached statements In order to use cached statements, make sure the DisableBind DBParm parameter is set to 0 (the default). This enables the binding of input variables to SQL statements.

For more about using bind variables, see DisableBind.

What happens The first time you execute a SQL statement containing bind variables, PocketBuilder does the following in this sequence:

  1. Parses the statement.

  2. For SQL SELECT statements, calls the appropriate database function to get a description of the result set.

  3. Allocates memory buffers for the bind variables.

  4. Binds the allocated memory buffers to the parsed statement.

When you cache this SQL statement, PocketBuilder stores the parsed statement, result set description, and memory buffer allocation and binding in the SQL cache. The next time you execute this statement, PocketBuilder finds it in the cache and avoids the overhead of repeating these steps.

If PocketBuilder finds an exact match for this statement in the SQL cache, it simply copies the new values supplied for the bind variables to the preallocated memory buffers and executes the statement. This is much faster than having to process the statement from scratch.

Determining the size of your SQL cache To determine an appropriate size for your SQL cache, you can check the value of the SQLReturnData property of the Transaction object.

When you disconnect from the database, the number of hits, misses, and entries in the SQL cache is stored in SQLReturnData as follows:

Examples

Example 1

To set the SQL cache size to 25 statements:

See also