Solved

Materialized Query Tables (MQT) in DB2

Posted on 2010-11-10
5
1,470 Views
Last Modified: 2012-05-10
Hi,

We have a project requirement which involves writing program that run on tables that are static. Our database is subject to constant change because the website is 24*7.

The database we use is DB2 on AS400. We were told by a consulting architect that using MQT might help us achieve what we are trying to do. And it was told that using an MQT might give us better performance as well.

Since I am new to the concept of MQT, i wanted to read on how to create, use and maintain a MQT. Any pointers or documents or web links which have details on MQT will be appreciated.

Thanks
Ali.
0
Comment
Question by:bhagatali
  • 2
  • 2
5 Comments
 
LVL 37

Expert Comment

by:momi_sabag
Comment Utility
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 125 total points
Comment Utility
although i'm not sure that this is exactly what you are looking for
MQT's should be use when you want DB2 to dynamically decide if to run your query against the base tables or against the MQT (you query is coded against the base tables).
In your case, your query should be coded against the MQT because you want a static view of the data,
so you can use any method of just freezing the data to a speceific poinit in time (by either copy it to other tables, or add a timestamp column and always get the rows up to a certain point in time)
0
 
LVL 45

Expert Comment

by:Kdo
Comment Utility

Can you post more of your requirements?  Also, why was an MQT recommended?  An MQT can be a wonderful thing, but their use can have a significant overhead, particularly when the data is very dynamic.

Essentially, an MQT is a table that contains a snapshot (or aggregation) of part of the base table.  Every time that the table is updated the MQT is also a candidate for update.


Kent
0
 

Author Comment

by:bhagatali
Comment Utility
Hi Kent,

The finance department in my company needs a report that can only be accurate if the data in the tables remain static. The report that is generated uses various columns from 3-4 tables. The report creation itself can take an hour or more to complete. To maintain accuracy on the report the finance team requested that we run the report on a database which doesn't change while the report is processing. With our website being 24*7, 1 hour is too big of a time frame for no changes to be occurring to the actual tables. It was then recommended that we use MQT to achieve 2 things:

1) Get a static snapshot of the columns from the tables we use.
2) Improve the overall performance of the reporting job.

Do you think the requirement warrants a look into the whole MQT thing or do you think there is a better way of doing this?

momi_sabag>> Thanks a lot for the link. The details in the link are helpful.

Regards
Ali.
0
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 125 total points
Comment Utility
Hi Ali,

Regarding the MQT, you'll have to weigh the overhead of building it with the urgency of creating the report.  If management is prone to picking up the phone and saying "I need that report ASAP" then you certainly need to takes steps to meet that.  If the conversation goes "Can I have that report by tomorrow?" you've got a bit more flexibility.

Keep in mind that an MQT is essentially a view where the results of that view are stored in another table.  You have options regarding how the update to the MQT is done so you may be able to stagger the potentially resource-heavy update to the MQT so that it doesn't impact your production environment.


Kent
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now