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 > Bufferpool Usage.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-24-11, 21:26
Rajesh1203 Rajesh1203 is offline
Registered User
 
Join Date: Aug 2010
Posts: 38
Bufferpool Usage.

Hello All,
I have a question regarding tablespaces and bufferpool usage.
Let's say there is tableA residing in TablespaceA which is pagesize 32K.
There is another Table tableB residing in TablespaceB which is of pagesize 4K.

Now If write a query to join both these tables which bufferpool will DB2 use?

Thanks
Rajesh.
Reply With Quote
  #2 (permalink)  
Old 08-24-11, 21:33
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
DB2 will not necessarily use any bufferpool for the result-set unless it has to spool it to temporary table first before returning the result to the SQL client. For example, if an ORDER BY is used, DB2 "may" have to write the result-set to the temporary table, but even this might be avoided if there is enough sort heap memory available (the amount of sort heap memory is determined by two of the db cfg parms, or by STMM if you are using that). Likewise, a nested loop join may not need any temporary table, while a very large merge-scan join might need one. If a temporary table is needed by DB2, then one of the system temporary tablespaces will be used that matches the size of the resultset, along with the appropriate bufferpool assigned to such a tablespace.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 08-25-11, 02:54
db2cap db2cap is offline
Registered User
 
Join Date: May 2010
Posts: 87
That was a nice question by rajesh.

@Marcus,
What you explained is true if we perform operations that will bring temporary tables into the picture. But what if its a simple join operation which does not need temporary table spaces?
Reply With Quote
  #4 (permalink)  
Old 08-25-11, 06:33
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by db2cap View Post
That was a nice question by rajesh.

@Marcus,
What you explained is true if we perform operations that will bring temporary tables into the picture. But what if its a simple join operation which does not need temporary table spaces?
I thought I explained that if no temporary table needs to be created by DB2, then there is no seperate bufferpool for the result-set, other than the bufferpools for the two tables being joined. Thre are obviously other memory heaps that DB2 uses to cache the result-set, but not bufferpools.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 08-25-11, 06:46
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
i believe this is wht marcus wanted to say. When there is simple join were every thing happens in bufferpool itself for 32k tablespace and 4k tablespace all works done in there own bufferpools IF the memory is not enought then it goes to temp tablespace and as marcus said then one of the system temporary tablespaces will be used that matches the size of the resultset, along with the appropriate bufferpool assigned to such a tablespace. Please correct me.

regds
Paul
Reply With Quote
  #6 (permalink)  
Old 08-25-11, 07:03
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by Mathew_paul View Post
i believe this is wht marcus wanted to say. When there is simple join were every thing happens in bufferpool itself for 32k tablespace and 4k tablespace all works done in there own bufferpools IF the memory is not enought then it goes to temp tablespace and as marcus said then one of the system temporary tablespaces will be used that matches the size of the resultset, along with the appropriate bufferpool assigned to such a tablespace. Please correct me.

regds
Paul
It is not just a question of whether there is memory in bufferpools for the tables being joined. It depends on whether DB2 needs to materialize the entire result-set before it can return the first row back to the SQL client. For example, if the SQL uses an ORDER BY, and DB2 cannot (or decides not to) process the results in the order requested by using an ordered index, DB2 will need to spool the entire result set somewhere before the first row can be returned. In the case of a sort, DB2 will try and use sort heap memory before spooling the result-set to a temporary table (which has its own bufferpool), but if the sort heap memory is not sufficient than a temporary table will be created in the system temporary tablespace and the bufferpool for the system temporary tablespace will be utilized.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 08-25-11, 08:06
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by Rajesh1203 View Post

Now If write a query to join both these tables which bufferpool will DB2 use?
None, one or the other, or both, depending on the query and its access plan.
Reply With Quote
  #8 (permalink)  
Old 08-25-11, 12:04
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Where does db2 allocate memory from to do the join? I think hash join will use sortheap. What about nested loop and merge?
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