12-22-03, 23:45 #1Registered User
- Join Date
- Dec 2003
Unanswered: How could the optimizer choose to use the MQT
I had built a summary table as follow:
db2 "create table db2inst1.thirdcube as (select a,b,c,sum(fact) as amount from db2inst1.fact1 group by cube(a,b,c) ) DATA INITIALLY DEFERRED REFRESH DEFERRED ENABLE QUERY OPTIMIZATION"
db2 "refresh table db2inst1.thirdcube"
db2 "RUNSTATS ON table db2inst1.thirdcube WITH DISTRIBUTION"
But when I run a qurey:
select a, sum(fact) from fact1 group by a
The db2expln shows that the query still used the base table fact1 instead of the summary table.
I also tried:
SET CURRENT REFRESH AGE ANY
SET CURRENT QUERY OPTIMIZATION 9
But it does not work.
Any one of you would help me figure it out?
Thanks a lot,
12-23-03, 00:17 #2Registered User
- Join Date
- May 2003
Do you ask this same question on comp.databases.ibm-db2? Did you try the suggestion to use the GROUPING() function for each nullable column that is part of the cube in the MQT definition to uniquely identify the row in the cube representing the rollup by A?M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390