58 High-Function Business Intelligence in e-business
GROUP BY cust_id
)
DATA INTITIALLY DEFERRED REFRESH DEFERRED
A user query that looks like the following will result in the materialized view
being ignored for optimization purposes. That is, rows corresponding to
cust_id between 400 and 500 are missing in the materialized view shown in
Example 2-31.
Example 2-31 Materialized view with more restrictive predicates — no match
SELECT cust_id, COUNT(*)
FROM trans
WHERE cust_id >= 400
GROUP BY cust_id
4. Query with an expression not derivable from materialized view:
Even if the expression used in the materialized view is not identical to that
used in the query, it might be possible to derive the expression used in the
query from that in the materialized view. However, it is possible for some
“obvious” matching cases to be ignored by DB2 due to precision or other
issues. These restrictions will eventually be handled in future.
Consider the materialized view shown in Example 2-32:
Example 2-32 Query: expression not derivable from materialized view
CREATE summary table custtrans AS
(
SELECT cust_id, SUM(sale_price) AS total, COUNT(items) AS countitems
FROM trans
GROUP BY cust_id
)
DATA INTITIALLY DEFERRED REFRESH DEFERRED
A user query that looks like that shown in Example 2-33 will result in the
materialized view being ignored for optimization purposes, since the
expression cannot be derived by DB2. However, it is possible for some
“obvious” matching cases to be ignored by DB2, either due to precision
issues, truncation issues, or a possibly not implemented as yet. Some of
these restrictions may eventually be handled in the future.
Example 2-33 Query: expression not derivable from materialized view — no match
SELECT cust_id, SUM(sale_price * 0.15) / COUNT(items)
FROM trans
GROUP BY cust_id