* in this query.
* @return true if the row counts should be checked, false otherwise
*/
protected boolean shouldWeCheckRowCounts() throws StandardException
{
final ExecPreparedStatement ps = getPreparedStatement();
/*
** Check the row count only every N executions. OK to check this
** without synchronization, since the value of this number is not
** critical. The value of N is determined by the property
** derby.language.stalePlanCheckInterval.
*/
int executionCount = ps.incrementExecutionCount();
/*
** Always check row counts the first time, to establish the
** row counts for each result set. After that, don't check
** if the execution count is below the minimum row count check
** interval. This saves us from checking a database property
** when we don't have to (checking involves querying the store,
** which can be expensive).
*/
if (executionCount == 1)
{
return true;
}
else if (executionCount <
Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL)
{
return false;
}
else
{
int stalePlanCheckInterval = ps.getStalePlanCheckInterval();
/*
** Only query the database property once. We can tell because
** the minimum value of the property is greater than zero.
*/
if (stalePlanCheckInterval == 0)
{
TransactionController tc = getTransactionController();
stalePlanCheckInterval =
PropertyUtil.getServiceInt(
tc,
Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
Integer.MAX_VALUE,
Property.DEFAULT_LANGUAGE_STALE_PLAN_CHECK_INTERVAL
);
ps.setStalePlanCheckInterval(stalePlanCheckInterval);
}
return (executionCount % stalePlanCheckInterval) == 1;
}