Monday, June 15, 2015

Package cache




What is the package cache?

            DB2 LUW uses many different memory areas to cache critical information. These memory areas are very powerful tools in controlling database performance. The package cache is one such area. This is where DB2 stores static and dynamic queries, access plans, and information about the execution of those queries.
 What information is in the package cache?
            Just like a gold mine, your package cache may seem like a black hole with an entire mountain of information behind it that you must sort through to find the gold nuggets that will make you rich. 

Few of the more interesting pieces of information available are:
Number of executions — the number of times a particular query has been executed
Execution time — the total time spent on all executions of a particular query
Lock wait time — the total time a particular query spent waiting on locks
Sort time — the total time a particular query spent organizing and ordering data
Rows read — the total number of rows a particular query has examined
Rows returned — the total number of rows a query has returned in result sets
CPU time — the total CPU time consumed by a particular query
Execution time — the total time a particular query spent executing
All information in the package cache is cumulative since the last time a particular query was placed in the package cache.
What information is NOT available in the package cache?

While the package cache contains a lot of useful information, it does not replace a SQL statement event monitor. 

The package cache cannot tell you:
             -When a particular query was executed, Some details on static SQL Specific values used in execution of a statement, when that statement uses parameter markers, Literal values used during execution .

How long does information stay in the package cache?

     DB2 moves individual statements in and out of the package cache to keep the most frequently executed statements in memory. Consequently, a statement might be in the package cache for a while before it is overwritten.
You can purge the contents of the package cache :

            FLUSH PACKAGE CACHE DYNAMIC

It is important to note that the execution of this statement can affect performance on a running system, since it will cause the access plans for all dynamic SQL to be re-generated.
Deactivating a database will also cause the package cache to be emptied.






Friday, May 8, 2015

Rebuild index



what is difference between rebuilding of indexes using reorg command and load command?

Two ways for rebuilding indexes: 
1) Reorg Indexes for all table tablename 
2) Load from /dev/null of del insert into tablename indexing mode rebuild
 

What is the difference between the above two? 

Rebuilding indexes using Load should be faster than Re-org indexes command. 

Observation 1: 
SORT Phase is running parallel in Load command. verify with db2pd -sort and -reorg index options. The output indicates two sort memory areas allocated and performed. 

Observation 2: 
SORT Phase is running one after another in REORG INDEXES ALL FOR TABLE command. The output of db2pd -sort and -reorg index options indicates one sort operation after another performed. 

> intra-parallel mode(CFG setting is NO) and running shared sorts only. 


Wednesday, April 15, 2015

LBAC overview



 Label Based Access Control

 >   SECADM authority
 >   security policy   ->  create/alter/drop

 > components :

           -name
           -type     tree/array/set



Friday, March 6, 2015

how can you identify if autoresize is enabled?



$db2 get snapshot for tablespaces on MYDB


For Automatic Storage check “Using automatic storage” – if it’s “1” than it’s enabled for Automatic Storage.For automatic resize check “Auto-resize enabled”   and if it’s “Yes”


Monday, March 2, 2015

backup


Take an OFFLINE backup 
db2 connect to <dbname>
db2 quiesce database immediate force connections
db2 connect reset
db2 backup database <dbname> to <path> compress without prompting
after backup completes:
db2 connect to <dbname>
db2 unquiesce database
db2 connect reset
Take an ONLINE Backup
db2 backup db <dbname> to <path> online compress
or use a background process on a linux/unix machine
nohup db2 backup db <dbname> to <path> online compress &
List recent backups and where they are stored
=>db2 list history backup all for <dbname>
Check the integrity of a backup image
=>db2ckbkp <image name>
Restore from Incremental Backup Automatic
=>db2 restore db <dbname> incremental automatic taken at <timestamp>
If you need to restore an incremental backup manually this command will give you the required previous backups.
=>db2ckrst -d <dbname> -t <timestamp of image>




Question:  How can I delete all FULL backups of a specific DB2 database  older than X amount of days?
Answer:  To delete FULL backups greater than X amount of days   , use this example as a basis and modify to your requirements. This example applies if you’re using TSM as the backup mechanism.

$db2adutl delete FULL older than 14 days  db MYDB