If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Views V Materialised Query Tables?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-01-11, 09:44
Breako Breako is offline
Registered User
 
Join Date: Jan 2006
Posts: 119
Views V Materialised Query Tables?

When should I create a View and when should I create a Materialised Query Table?

I get the idea that Materialised Query Tables are more intended for performance but would like more specifics.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 08-01-11, 10:41
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
Hi,

it depends on the view and what you want to achieve with it.
If the view just select a subset of data (e.g. select * from cars where color='red'), you should stick with the view. Also if the view is implemented to ease implementation of query (e.g. often used simple joins).

If the view is used by many queries and includes some expensive aggregations, you should consider to switch it into a MQT. It also depends on how often the underlying data changes and the need of updating the data in the MQT.

hth
Reply With Quote
  #3 (permalink)  
Old 08-01-11, 13:44
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
Views are best used when you need to restrict different users/groups for multiple numbers of limited view of the entire table. E.g. From the Employee table, you want to allow all employees to view details about all others employees' Names and Department, but want to allow only the Senior Managers to view the entire detail of the employees including wages, address, band etc. So you will allow the employee group with SELECT access on view V_EMP_Contact and will grant SELECT access to group created for the managers on view V_EMP_DETAILs which has got the entire details for all employees ( from the EMPLOYEE table). There are many other uses of Views as well like your table contains too many fields, whereas almost all the user queries are interested only in a subset of the same.

For Materialized query tables, as you correctly mentioned, they are created for performance primarily and are physical copies in the form of a table of the query output that is embedded in the definition of the MQT. There are lot many white papers and redbooks available on MQTs in the net.
__________________

Jayanta Datta
DB2 UDB DBA
IBM India, Global Delivery
New Delhi

Last edited by JAYANTA_DATTA; 08-01-11 at 13:48.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On