• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1541
  • Last Modified:

Materialized Query Tables (MQT) in DB2

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
bhagatali
Asked:
bhagatali
  • 2
  • 2
2 Solutions
 
momi_sabagCommented:
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
 
Kent OlsenData Warehouse Architect / DBACommented:

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
 
bhagataliAuthor Commented:
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
 
Kent OlsenData Warehouse Architect / DBACommented:
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now