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 > Clear/flush out bufferpool

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-10, 11:07
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Clear/flush out bufferpool

Hi,

Is there a simple command I can run to clear out the bufferpools? I'm testing out the speed of certain queries and want to make sure that it's tested with nothing pre-calculated in memory.. thanks!!
Reply With Quote
  #2 (permalink)  
Old 10-13-10, 12:34
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Seems like ipclean, stop, start of database will do it for me.. found this article :

How to empty the buffer pool?
Reply With Quote
  #3 (permalink)  
Old 10-13-10, 17:21
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Just restart the db. Don't use ipclean unless you're unable to force the applications off the db
Reply With Quote
  #4 (permalink)  
Old 10-14-10, 15:17
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
today, it seems like the clearing of the bufferpool is simply not working.. if I execute a query, restart db2 and execute the same query.. it seems to give the result really fast the 2nd time around when it should take just as long as it did before the restart.

For some reason, it cleared it out better yesterday and I haven't changed any of the steps in clearing it out either... so not sure what is causing this.. !!
Reply With Quote
  #5 (permalink)  
Old 10-14-10, 21:06
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Quote:
Originally Posted by db2user24 View Post
it seems like the clearing of the bufferpool is simply not working
Did you restart your db before each run and only executed the query once? Use db2pd -buf to check the bufferpool statistics. They should be very similar for every run assuming you execute your query once and then restart the db. See my example. In the last db2bp output, hit ratio is higher because I ran the same query twice without restarting the db.
Attached Files
File Type: txt db2pd.buf.txt (5.3 KB, 49 views)
Reply With Quote
  #6 (permalink)  
Old 10-14-10, 21:18
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
And there is only one tablespace/table assigned to this bp, system catalog is assigned to the default bp.
Reply With Quote
  #7 (permalink)  
Old 10-14-10, 22:42
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Let's be more clear about restarting. You need to stop (db2stop) and start (db2start) the instance (database manager), not restart the database (there is a RESTART DATABASE command that is different from stop/stop of instance).

You might be able to flush the bufferpools if you force all connections from the database, and then deactivate the database, then activate the database again (without having to stop/stop the instance).
__________________
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
  #8 (permalink)  
Old 10-14-10, 22:54
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Quote:
Originally Posted by db2user24 View Post
Hi,

Is there a simple command I can run to clear out the bufferpools? I'm testing out the speed of certain queries and want to make sure that it's tested with nothing pre-calculated in memory.. thanks!!
This is contrary to the way DB2 normally works, since at least some data for every query (even if only the root index pages) should remain in memory. Any decent DBA should be able to configure BP's to keep most of the indexes in memory most of the time, in addition to keeping frequently used data pages in memory for small and medium size tables.

So whatever bufferpool states you are trying to setup are not representative of real world conditions, and your results will likely cause misleading conclusions regarding performance. If you want a theoretical number to compare performance of two queries (or the same query with two different indexes, etc), do an Explain and look at timerons.

For TPC-H benchmarks (TPC - Homepage) of data warehouse queries, the test specifies that each query be run 10 times and results are averaged. They do not require a flushing of bufferpools before each run.
__________________
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
  #9 (permalink)  
Old 10-14-10, 23:31
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
I was the one connected to the db so it was enough to do db2 terminate to flush the bufferpools. I repeated the same thing:

- restarted instance and connected to db
- in the db2pd -buf output, I see some numbers even before I run the query:

DatLRds DatPRds HitRatio TmpDatLRds TmpDatPRds HitRatio IdxLRds IdxPRds HitRatio TmpIdxLRds TmpIdxPRds HitRatio
72 68 05.56% 0 0 00.00% 0 0 00.00% 0 0 00.00%


- in the db2pd -pages summary output, I see:

BPID TbspaceID ObjID Total Dirty Permanent Temporary Data Index LongField XMLData SMP LOB LOBA BMP
8 12 65534 33 0 33 0 0 0 0 0 33 0 0 0
8 12 65535 1 0 0 0 1 0 0 0 0 0 0 0


object 65534 and 65535 are some internal stuff (they belong to SMP and object table, I believe).


- executed query:

BPID TbspaceID ObjID Total Dirty Permanent Temporary Data Index LongField XMLData SMP LOB LOBA BMP
8 12 4 863 1 862 0 863 0 0 0 0 0 0 0
8 12 65534 33 0 33 0 0 0 0 0 33 0 0 0
8 12 65535 2 0 1 0 2 0 0 0 0 0 0 0


object id 4 is my table


- db2 terminate and connect to db


BPID TbspaceID ObjID Total Dirty Permanent Temporary Data Index LongField XMLData SMP LOB LOBA BMP
8 12 65534 33 0 33 0 0 0 0 0 33 0 0 0
8 12 65535 1 0 0 0 1 0 0 0 0 0 0 0



Terminating my connection flushed the bp.
Reply With Quote
  #10 (permalink)  
Old 10-15-10, 15:02
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Quote:
Originally Posted by db2girl View Post
Did you restart your db before each run and only executed the query once? Use db2pd -buf to check the bufferpool statistics. They should be very similar for every run assuming you execute your query once and then restart the db. See my example. In the last db2bp output, hit ratio is higher because I ran the same query twice without restarting the db.


Thanks, I restarted the db before each run.. when I run the db2pd command, I get back the top lines in your file but I don't get this --



Bufferpool Statistics for bufferpool 8 (when BUFFERPOOL monitor switch is ON):

DatLRds DatPRds HitRatio TmpDatLRds TmpDatPRds HitRatio IdxLRds IdxPRds HitRatio TmpIdxLRds TmpIdxPRds HitRatio
1851 935 49.49% 0 0 00.00% 0 0 00.00% 0 0 00.00%

DataWrts IdxWrts DirRds DirRdReqs DirRdTime DirWrts DirWrtReqs DirWrtTime
0 0 0 0 0 0 0 0

AsDatRds AsDatRdReq AsIdxRds AsIdxRdReq AsRdTime AsDatWrts AsIdxWrts AsWrtTime
861 27 0 0 82 0 0 0

TotRdTime TotWrtTime VectIORds VectIOReq BlockIORds BlockIOReq FilesClose NoVictAvl UnRdPFetch
162 0 861 27 0 0 0 0 0




I thought I had turned the monitoring on.. but I guess I messed up somewhere.


Btw, I'm a fan of panipuri too!!!
Reply With Quote
  #11 (permalink)  
Old 10-15-10, 16:30
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Marcus and db2girl, since we're talking about bufferpools, performance, etc I have a general question for you two --

If you were on a web application and wanted to see the monthly sum of reading values where the total number of records to sum up = 124,320 records ( total in table are in the billions), what's a reasonable amount of time you would expect it to come back with a result?
Reply With Quote
  #12 (permalink)  
Old 10-15-10, 22:21
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Quote:
Originally Posted by db2user24 View Post
Marcus and db2girl, since we're talking about bufferpools, performance, etc I have a general question for you two --

If you were on a web application and wanted to see the monthly sum of reading values where the total number of records to sum up = 124,320 records ( total in table are in the billions), what's a reasonable amount of time you would expect it to come back with a result?
There is no accurate way to answer that since there are too many variables involved regarding your hardware setup (memory, CPU, etc) not to mention the other applications running.

But the response time primarily depends on whether the 124,320 rows can be retrieved efficiently via an index, or whether a table scan of several billion rows is necessary. But I would make sure you had the prefetch settings correct (and they are in synch with containers and extents), and also that you had parallel I/O set correctly in your db2set variables. If an index can be used, it should probably be in a separate tablespace and a separate bufferpool from the data tables.

I would do an explain on the statement to understand what the access plan is (index vs table scan, etc). But tuning one query in isolation of all other SQL statements in the application is treacherous.
__________________
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
  #13 (permalink)  
Old 10-18-10, 15:52
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Thanks Marcus! You're right.. there are many factors that would determine the processing time for such a query. In my experience, end users ( web app customers) don't really have much patience when it comes to data retrieval so we really want the report to come up in seconds.

Can you explain why you recommend the index should be in a separate tablespace / bufferpool from the table?
Reply With Quote
  #14 (permalink)  
Old 10-18-10, 15:53
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Thanks a lot for the tips!
Reply With Quote
  #15 (permalink)  
Old 10-18-10, 17:53
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Quote:
Originally Posted by db2user24 View Post
Thanks Marcus! You're right.. there are many factors that would determine the processing time for such a query. In my experience, end users ( web app customers) don't really have much patience when it comes to data retrieval so we really want the report to come up in seconds.

Can you explain why you recommend the index should be in a separate tablespace / bufferpool from the table?
Becasue for most databases, you want to have a higher bufferpool hit ratio for indexes compared to tables (this assumes that you cannot make bufferpools large enough to have all data and indexes in memory all the time).

So as an example, you may want something like the following (this may not be accurate for your particular database, but you should be able to understand the principles involved):

1. Bufferpool 1 (bufferpool is about 80-100% of the size of assigned tablespaces):
  • Syscatspace (system catalog)
  • Small tables
  • Indexes on Small tables
  • Indexes on Medium Tables
2. Bufferpool 2 (bufferpool is about 25-50% of the size of assigned tablespaces).
  • Medium Size Tables
  • Indexes on Large Tables
3. Bufferpool 3 (bufferpool is 15% or less of the size of assigned tablespaces)
  • Large Tables
  • System Temp Tablespaces

In the above scenario, the 3 bufferpools may be about equal in size (or maybe not), but because they have different desired bufferpool hit ratios, they have different amounts of data (from tablespaces) assigned to them.
__________________
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
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