473,804 Members | 3,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MQT table use by optimizer


Using a base table, a MQT table was created. With optimization - when
querying the base table with calcuation that are already completed in
the MQT - I would assume the optimizer would use the MQT table instead
of the base table.

What causes the optimizer to use the MQT tables rather than the tables
as defined by the query? Is there a way to "encourage" use of the MQT
tables?

Thanks.

Dec 8 '06 #1
5 3059
Check for this in the documentation

SET CURRENT REFRESH AGE= ANY

cheers..
Shashi Mannepalli
Kevin wrote:
Using a base table, a MQT table was created. With optimization - when
querying the base table with calcuation that are already completed in
the MQT - I would assume the optimizer would use the MQT table instead
of the base table.

What causes the optimizer to use the MQT tables rather than the tables
as defined by the query? Is there a way to "encourage" use of the MQT
tables?

Thanks.
Dec 10 '06 #2

Shashi,

I am using explain to verify that the mqt table is being used. Should
set current refresh age be included prior to executing my sql
statement?

Thanks.

Shashi Mannepalli wrote:
Check for this in the documentation

SET CURRENT REFRESH AGE= ANY

cheers..
Shashi Mannepalli
Kevin wrote:
Using a base table, a MQT table was created. With optimization - when
querying the base table with calcuation that are already completed in
the MQT - I would assume the optimizer would use the MQT table instead
of the base table.

What causes the optimizer to use the MQT tables rather than the tables
as defined by the query? Is there a way to "encourage" use of the MQT
tables?

Thanks.
Dec 11 '06 #3
Yes

SET CURRENT REFRESH AGE=ANY

SELECT YEAR(pdate) AS year, SUM(ti.amount) AS amount
FROM cube.transitem AS ti, cube.trans AS t,
cube.loc AS loc, cube.pgroup AS pg,
cube.prodline AS l
WHERE ti.transid = t.id
AND ti.pgid = pg.id
AND pg.lineid = l.id
AND t.locid = loc.id
AND YEAR(pdate) IN (1995, 1996)
GROUP BY year(pdate);

An example i saw in this

http://publib.boulder.ibm.com/infoce.../v8//index.jsp

There are some restrictions/instructions also available in the above
link.
Search for CURRENT REFRESH AGE in that link

cheers..
Shashi Mannepalli
Kevin wrote:
Shashi,

I am using explain to verify that the mqt table is being used. Should
set current refresh age be included prior to executing my sql
statement?

Thanks.

Shashi Mannepalli wrote:
Check for this in the documentation

SET CURRENT REFRESH AGE= ANY

cheers..
Shashi Mannepalli
Kevin wrote:
Using a base table, a MQT table was created. With optimization - when
querying the base table with calcuation that are already completed in
the MQT - I would assume the optimizer would use the MQT table instead
of the base table.
>
What causes the optimizer to use the MQT tables rather than the tables
as defined by the query? Is there a way to "encourage" use of the MQT
tables?
>
Thanks.
Dec 11 '06 #4
Shashi,

if you created a "refresh immediate" MQT it will be used in any case
when the query benefits from the MQT.

if you created the MQT with "refresh deferred" it depends whether the
MQT is maintained by system or maintained by user.

maintained by system (default):
use set current refresh age = any

there is another register:
set current maintained table types for optimization (default = SYSTEM)

maintained by user:
set current maintained table types for optimization [USER|ALL]

You can set that register or set the DB CONFIG PARAM:
DB2 UPDATE DATABASE CONFUGURATION FOR [DBNAME] USING DFT_MTTB_TYPES
[USER|SYSTEM|ALL]

Not sure if this still applies to Version 8.2 but if you already run a
SQL statement prior to the creation of the MQT the SQL might still
reside in the dynamic statement cache and if you created the MQT it
might not be considered by the optimizer because of the existing plan
in the cache. So to be sure from command line issue a:

FLUSH PACKAGE CACHE--DYNAMIC
in order to have the optimizer creating a fresh access path

This articel covers a lot of the MQT world:
http://www-128.ibm.com/developerwork...le/dm-0605lin/

Last but not least: In Version UDB 7 the visual explain was not able to
show the usage of an MQT allthough it was used. Step 10 of the
developer works articel covers the access paths of MQT usage.

I hope that helps
Cheers
Florian

-------------------------
Speedgain for DB2 LUW - Performance Monitoring for DB2 UDB LUW

Kevin schrieb:
Shashi,

I am using explain to verify that the mqt table is being used. Should
set current refresh age be included prior to executing my sql
statement?

Thanks.

Shashi Mannepalli wrote:
Check for this in the documentation

SET CURRENT REFRESH AGE= ANY

cheers..
Shashi Mannepalli
Kevin wrote:
Using a base table, a MQT table was created. With optimization - when
querying the base table with calcuation that are already completed in
the MQT - I would assume the optimizer would use the MQT table instead
of the base table.
>
What causes the optimizer to use the MQT tables rather than the tables
as defined by the query? Is there a way to "encourage" use of the MQT
tables?
>
Thanks.
Dec 13 '06 #5
Ian
Kevin wrote:
Shashi,

I am using explain to verify that the mqt table is being used. Should
set current refresh age be included prior to executing my sql
statement?
You can also set the DFT_REFRESH_AGE database configuration parameter
in the event that you can't force all clients to issue the SET CURRENT
REFRESH AGE register.

Dec 14 '06 #6

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

Similar topics

5
33665
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. Performance: 4 seconds, the system is doing a full-table scan of the second table, and the Explain Plan output
36
4658
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am proposing a single column table with a field name called vehicle_type and this will contain the vehicle type. Sot it will be
12
7703
by: TP | last post by:
Here is my problem. I need to display a table about which I have no information except the table name. Using metadata I can somehow show the column names and record values. But my table has 1 million rows and if I do a select * then I do get 1 million rows. I want to be able to provide page navigation as google does, page
7
19998
by: sql-db2-dba | last post by:
Does DB2 just fudge it when it is an empty table? Is there a "formula" for average row size when you have variable length records. Or you really have to know what your application is packing into those varchar columns. Bill Leung leungb@aptea.com
9
2806
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 the following commands: set current query optimization 9;
0
1252
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 there is no order by in query. Has anyone read that this is a limitation? create summary table s_t as (select f1, f2, count(*) from t1 group by f1, f2) select distinct f1, f2 from t1 - explain shows optimizer uses s_t
2
2084
by: Szymon Dembek | last post by:
Hi I'm trying to tune access times on a table which size might vary (from 0 to at least several thousand records). I've tried marking this table 'volatile' but it caused performance penalties on some operations: - table scan from 10 to 200 timerons - index scan from 15 to 500 timerons
3
8764
by: Otto Carl Marte | last post by:
>From the IBM db2 docs: http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/t0005308.htm it says that volatile tables (ALTER TABLE mytable VOLATILE CARDINALITY) do not use statistics. I would just like to clarify this statement. Does this mean that no statistics at all are used when determining the execution plan? or does this mean that statistics applying to cardinality are not used when...
7
2760
by: Henry J. | last post by:
I got a dumb question on the merge statement. I read the following example of merge statement at the IBM page: http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0010873.htm: MERGE INTO archive ar USING (SELECT activity, description FROM activities) ac ON (ar.activity = ac.activity) WHEN MATCHED THEN UPDATE SET description = ac.description
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10588
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.