473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 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,
Angela
Nov 12 '05 #1
4 4360
I think you should do the select straight from the MQT table , not from
fact1.

Angela wrote:
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 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,
Angela


--
Anton Versteeg
IBM Certified DB2 Specialist
IBM Netherlands
Nov 12 '05 #2
AK
Angela,

have you tried "group by a,b,c" instead of "group by cube(a,b,c)"?
Nov 12 '05 #3
One of the points of using MQT's is that the optimizer is supposed to
do query rewrite to use this table. Angela's question is valid and
warrants an answer not a workaround.
Anton Versteeg <an************@nnll.iibbmm.com> wrote in message news:<3F**************@nnll.iibbmm.com>...
I think you should do the select straight from the MQT table , not from
fact1.

Angela wrote:
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 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,
Angela

Nov 12 '05 #4
Angela wrote:
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 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,
Angela


This query should route to your MQT. Are the columns A,B,C nullable?
If yes, we usually recommend including the GROUPING() function for
each nullable column that is part of the cube in the MQT definition.
Otherwise we might not be able to uniquely identify the row in the
cube representing the rollup by A.

Regards,
Miro

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Bupp Phillips | last post by:
I have a customer table that has the field CUSTOMER_ID as the primary key (cust_pkkey), the table has 102,834 records in it. The following select statement works fine: select * from customer...
9
by: Andrea | last post by:
Hi, I've read the former postings but was not able to solve my problem: I have a Summary Table (or MQT as you like it) and the query optimizer does not seem to use the summary table. I run...
6
by: Ian Ribas | last post by:
Hello, This is probably a common problem, but I couldn't really find a direct answer in the archives (or maybe just couldn't find one that satisfied me ;-). I created an index specifically to...
0
by: Rob K. | last post by:
I have a new summary table built againt a single data table. Simple select, count(*) and group by type. After I built it, I found that the optimizer will choose to use it for existing queries IF...
5
by: Venkatesh Subbaramu | last post by:
Hi Expert DBAs, I am facing an issue with a query, can anyone help me through? I have a Query: UPDATE VMUS.MSG_MSTR a SET MSG_STA_ID =5 WHERE a.PROC_ID =2 AND a.file_type_id =1 AND MSG_STA_ID...
0
by: Larry Bertolini | last post by:
While trying to help a developer troubleshoot a performance problem, I have discovered something that strikes me as odd. When I run a particular query, using a non-privileged login that has...
3
by: aj | last post by:
DB2 LUW v8.2 FP 14 RHAS 2.1 Sorry if these are newbie questions. Optimizer stuff is black magic to me. For both of these, assume stats are current and an even distribution of data....
1
by: martely | last post by:
Hello, DB2 V8 FP10 We are doing some performance tunning with an MDC table and we found unexpected access plans with columns used for range and IN predicates (Optimization class 7). Our MDC...
7
by: skaushik | last post by:
Hi all, I was working on a SQL query where a history table is joined with a small table to get some information. There is an index on the history table column but the explain plan tells that there...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.