Search condition order
- Last Updated: May 12, 2026
- 1 minute read
- OpenAccess SDK
- Version 8.1
- Documentation
The condition should be on an index column. The OpenAccess SDK SQL engine selects the best search condition, using the following criteria:
- Select the search condition with the = operator.
- Select the condition on a unique index column.
- Select the condition with the best cardinality (high cardinality index is preferred). Note that the cardinality of a unique index would represent the total number of records in the table.
The following queries show the selection process for search condition based ordering:
SELECT ... FROM dept, div, emp
WHERE emp.empno = 2 AND emp.deptno=dept.deptno AND dept.divno=div.divno
- SELECT
empas the first table to be processed because it has a search condition (empno=2). - SELECT
deptas the next table because it has a relationship condition with theemptable. - SELECT
divnext because it has a relationship condition with thedepttable.
The query is processed in this order: emp,dept,div
SELECT ... FROM dept, div, emp
WHERE div.divno = 1 AND emp.empno = 2 AND emp.deptno=dept.deptno
AND dept.divno=div.divno.
SELECT empas the first table to be processed because the index on search condition (empno=2) has higher cardinality than the index on search condition (divno=1).SELECT deptas the next table because it has a relationship condition with theemptable.SELECT divnext because it has a relationship condition with thedepttable.