Category: DB2 Admin SQL Cookbook

select2 4

DB2 Administrative SQL Cookbook: Generating a Comma Separated List of Columns in a MON_GET Table Function

Purpose To generate a comma separated list of columns in a MON_GET table function, in the same order you should get the columns if you query the table. This SQL should handle larger tables like MON_GET_DATABASE that have a very large number of columns. This is especially useful when pulling data into Excel to play with it or getting it...

select2 0

DB2 Administrative SQL Cookbook: When Were Runstats Done (Beyond STATS_TIME)?

Purpose To list all RUNSTATS done in a database in the last three days, whether manual or automatic. Version Tested on 10.5. Should work on 10.1 and up. Statement select pid, tid, substr(eventtype, 1, 10), substr(objtype, 1, 30) as objtype, substr(objname_qualifier, 1, 20) as objschema, substr(objname, 1, 10) as objname, substr(first_eventqualifier, 1, 26) as event1, substr(second_eventqualifiertype, 1, 2) as event2_type,...

DSC06398 0

Calculating Row Size for a Table

There are several scenarios with DB2 where we need to know what the “worst-case” row length is. That is, if all varying fields are completely full and any LOBs are maximally inlined, how much space could a single row actually take up? SYSCAT.TABLES gives us the average row size, which is useful for some use cases, but not all of...

select2 0

Administrative SQL Cookbook: BLU Buffer Pool Hit Ratios

Purpose These statements calculates the buffer pool hit ratio for both BLU and non-BLU activity. This post includes three SQLs – for calculating at the database, bufferpool, and tablespace level. The separate BLU calculations are not yet included in sysibadm.bp_hitratio as of the writing of this article. Source While I’ve modified this statement, it comes from these two sources, both...

select 2

DB2 Administrative SQL Cookbook: Column Selectivity by Table (BLU)

Purpose This statement reports how selective at the column level queries are that run against a specific table. This does not look at overall selectivity or row selectivity. It will only work in DB2 10.5. BLU performs best when not all columns are referenced by queries. Source While I’ve modified this statement, it started with statements from these two sources,...

select2 0

DB2 Administrative SQL Cookbook: BLU Compression Ratios

Purpose This statement calculates the compression ratio for BLU tables. The compression ration can be used to help identify tables where compression is not optimal and you may need to look into why. Compression is critical to optimal performance on BLU. Understanding Compression Ratios. Compression ratios across platforms and outside of databases are generally represented as: Compression Ratio = Compressed...