Solved

Materialized Query Tables (MQT) in DB2

Posted on 2010-11-10
5
1,478 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
ID: 34103409
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 125 total points
ID: 34103427
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:Kent Olsen
ID: 34103958

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
ID: 34105093
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:Kent Olsen
Kent Olsen earned 125 total points
ID: 34105250
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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