Constraint key query

Previous Next

At store-record time, in an operation known as a constraint key query, the Rules Engine may attempt to get primary key information of records being processed. This is because database values needed during later transaction checks will be retrieved faster if primary key values can be used.

Constraint key queries are identified in BenchMark profiler output as having Reason = CONSTRAINT_KEYQUERY.



A business rule: "A guide cannot guide more than one tour at the same time" is implemented by a restrictive constraint:

SELECT    '' violation
FROM      schedtour st1
,         schedtour st2
AND       st1.schedtour_id != st2.schedtour_id
AND       st1.start_date BETWEEN st2.start_date AND st2.return_date

In this constraint, there is no join based on relationship columns (because there is no relationship). When a manipulation takes place on the SCHEDTOUR table, a constraint key query is issued to retrieve the primary key values of the driving table (SCHEDTOUR st1). These primary key values are substituted during the transaction check at commit time:

          t1.GUIDE = TO_NUMBER(:1)
              TO_DATE(:3, 'SYYYY/MMDDHH24MISS') AND
              TO_DATE(:4, 'SYYYY/MMDDHH24MISS')

This check will now perform much faster than without the primary key information.


See also

Transaction checklist signals

Constraint evaluation order