Monitoring usage of the SQL statement cache
If you notice a sudden increase in response time for a query that had been using the SQL statement cache, the entry might have been dropped or deleted. You can monitor the usage of the SQL statement cache and check for a dropped or deleted entry by displaying onstat -g ssc command output.
- Execution of any data definition language (DDL) statement (such as ALTER TABLE, DROP INDEX, or CREATE INDEX) that might alter the query plan
- Alteration of a table that is linked to another table with a referential constraint (in either direction)
- Execution of UPDATE STATISTICS FOR TABLE for any table or column involved in the query
- Renaming a column, database, or index with the RENAME statement
When an entry is marked as dropped or deleted, the database server must reparse and reoptimize the SQL statement the next time it executes. For example, Sample onstat -g ssc command output for a dropped entry shows the entries that the onstat -g ssc command displays after UPDATE STATISTICS was executed on the items and orders table between the execution of the first and second SQL statements.
Statement Cache Entries
portion of the onstat -g ssc
output in Sample onstat -g ssc command output for a dropped entry displays a flag field that indicates
whether or not an entry has been dropped or deleted from the SQL statement cache. - The first entry has a flag column with the value
DF
, which indicates that the entry is fully cached, but is now dropped because its entry was invalidated. - The second entry has the same statement text as the third entry, which indicates that it was reparsed and reoptimized when it was executed after the UPDATE STATISTICS statement.
Invalidating a statement
You can selectively invalidate entries of your choice by setting the sysmaster:syssscelem:valid column to 0 as user Informix
For example, Figure 2 shows the entries that the onstat -g ssc command displays before and after invalidating a query from the items table
The Statement Cache Entries portion of the onstat -g ssc output in Figure 2 displays a flag field that indicates whether or not an entry has been invalidated in the SQL statement cache.
Locking a statement
You can lock an entry of your choice in the Statement Cache even when UPDATE STATISTICS is executed on tables in the sql statement.
For example, Figure 3 shows the entries that the onstat -g ssc command displays after UPDATE STATISTICS was executed on the items table between the execution of the first and second SQL statements.
The Statement Cache Entries
portion of the onstat -g ssc
output in Figure 3 displays a flag field that
indicates whether or not an entry has been locked in the SQL statement cache.