A predicate is an element of a search condition that expresses
or implies a comparison operation. Predicates are included in clauses
beginning with WHERE or HAVING.
For example, in the following SQL statement:
SELECT * FROM SAMPLE
WHERE NAME = 'SMITH' AND
DEPT = 895 AND YEARS > 5
The following are predicates: NAME = 'SMITH';
DEPT = 895; and YEARS > 5.
Predicates fall into one of the following categories, ordered from most
efficient to least efficient:
- Starting and stopping conditions bracket (narrow down) an index
scan. (These conditions are also called range-delimiting
predicates.)
- Index-page (also known as index sargable) predicates can be evaluated from
an index because the columns involved in the predicate are part of the index
key.
- Data-page (also known as data sargable) predicates cannot be evaluated
from an index, but can be evaluated while rows remain in the buffer.
- Residual predicates typically require I/O beyond the simple accessing of a
base table, and must be applied after data is copied out of the buffer
page. They include predicates that contain subqueries, or those that
read LONG VARCHAR or LOB data stored in files separate from the table.
When designing predicates, you should aim for the highest selectivity possible so that the fewest rows are
returned.
The following types of predicates are the most effective and the most
commonly used:
- A simple equality join predicate is required for a merge
join. It is of the form table1.column = table2.column,
and allows columns in two different tables to be equated so that the tables
can be joined.
- A local predicate is applied to one table only.
For more information,
see
the sections on data access concepts and optimization in the
Administration Guide.
[ Top of Page |
Table of Contents |
Glossary |
Index ]
[ DB2 List of Books |
Search the DB2 Books ]