Stage 1 and stage 2 predicates

Stage 1 and stage 2 predicates

Rows retrieved for a query go through two stages of processing. Certain predicates can be applied during the first stage of processing, whereas other cannot be applied until the second stage of processing. You can improve the performance of your queries by using predicates that can be applied during the first stagewhenever possible.

Begin program-specific programming information. Predicates that can be applied during the first stage of processing are called Stage 1 predicates. These predicates are also sometimes said to besargable. Similarly, predicates that cannot be applied until the second stage of processing are called stage 2 predicates, and sometimes described asnonsargable or residual predicates.

Whether a predicate is stage 1 or stage 2 depends on the following factors:

  • The syntax of the predicate.
  • Data type and length of constants or columns in the predicate.

    Start of changeA simple predicate whose syntax classifies it as indexable and stage 1 might not be indexable or stage 1 because of data types that are associated with the predicate. For example, a predicate that is associated with either columns or constants of the DECFLOAT data type is never treated as stage 1. Similarly a predicate that contains constants or columns whose lengths are too long also might not be stage 1 or indexable.End of change

    For example, the following predicate is not indexable:

    CHARCOL

    The predicate is not indexable because the length of the column is shorter than the length of the constant.

    The following predicate is not stage 1:

    Start of change
    DECCOL>34.5e0, where DECCOL is defined as DECIMAL(18,2)
    End of change

    The predicate is not stage 1 because the precision of the decimal column is greater than 15.

  • Whether DB2® evaluates the predicate before or after a join operation. A predicate that is evaluated after a join operation is always a stage 2 predicate.
  • Join sequence.

    The same predicate might be stage 1 or stage 2, depending on the join sequence. Join sequence is the order in which DB2 joins tables when it evaluates a query. The join sequence is not necessarily the same as the order in which the tables appear in the predicate.

    For example, the predicate might be stage 1 or stage 2:

    T1.C1=T2.C1+1

    If T2 is the first table in the join sequence, the predicate is stage 1, but if T1 is the first table in the join sequence, the predicate is stage 2.

    You can determine the join sequence by executing EXPLAIN on the query and examining the resulting plan table.

All indexable predicates are stage 1. The predicate C1 LIKE %BC is stage 1, but is not indexable.

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21018850/viewspace-1021614/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/21018850/viewspace-1021614/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值