Pages

Monday, March 24, 2014

Difference in interrupt counts from /proc/interrupts


The following python script can be used to determine interrupt counts occurred between the before and after "cat /proc/interrupts":

#!/usr/bin/python
'Interrupt counts between before and after /proc/interrupts snapshots'

import sys
from itertools import izip

def checkUsage():
    #Check Usage
    if len(sys.argv) < 3:
        print "Usage ->"
        print sys.argv[0]," </proc/interrupts before> </proc/interrupts after>"

def readFiles(fileName1, fileName2):
    fileA = open(fileName1)
    fileB = open(fileName2)
    for lineA, lineB in izip(fileA, fileB):
        wordsA = lineA.rstrip().split()
        wordsB = lineB.rstrip().split()
        for wordA, wordB in izip(wordsA, wordsB):
            if wordA.isdigit() and wordB.isdigit():
                sys.stdout.write("%s%s" % (str(int(wordB) - int(wordA)),"\t"))
            else:
                sys.stdout.write("%s%s" % (wordB," "))
        print

def main():
    checkUsage()
    #readFile(sys.argv[1])
    readFiles(sys.argv[1], sys.argv[2])

#Don't execute if script is imported instead of executed
if __name__ == '__main__':
    main()

Please leave me a comment if you find this post helpful.

Wednesday, March 5, 2014

Oracle RDBMS tips


Monitoring

Tables/Indexes

  • desc user_tables
  • desc user_indexes

DB CPU

  • V$SYSSTAT: Oracle CPU usage for all sessions. The parse time cpu statistic shows the total CPU time used for parsing.
  • V$SESSTAT: Oracle CPU usage for each session. 
  • select * from v$resource_limit;
  • select count(*) from V$process;

Wait Events

  • db file sequential read: usually single block INDEXED reads [1]. Faster disks or more spindles will help. Larger buffer cache may help.
  • db file scattered read
  • db file single write
  • db file parallel write
  • log file parallel write

Latches

  • HW enq
  • Latch: Cache Buffer Chain - Ref [2]
    -- Find memory address:
    SELECT 
          addr,
          sleeps
    FROM 
          v$latch_children c,
          v$latchname n
    WHERE
          n.name='cache buffers chains' and
          c.latch#=n.latch# and
          sleeps > 100
    ORDER BY sleeps;
    
    -- Find file and block numbers:
    
    SELECT file#, dbablk, class, state, TCH
      FROM X$BH
      WHERE HLADDR='address of latch';
    -- Find segment name from dba_segments
Data/Log/Sys Files

  • select name from v$datafile;
  • select name from v$controlfile;
  • select member from v$logfile;


Performance Tuning Recommendations

  • #Transactions = based on the application, the number of concurrent transactions that can occur
  • #Sessions = (1.1 * PROCESSES) + 5
  • DML_LOCKS = #Transactions * (avg #SQLs per transaction)
  • REPLICATION_DEPENDENCY_TRACKING: disable where replication is not required as skipping tracking generation will make read/write operations faster  

Recovery


References

[1] http://asktom.oracle.com/pls/asktom/f?p=100:11:0:::%3AP11_QUESTION_ID:6265095774206
[2] https://docs.oracle.com/cd/B16240_01/doc/doc.102/e16282/oracle_database_help/oracle_database_wait_bottlenecks_latch_cache_buffer_chains_pct.html