Saturday, September 5, 2015

monitoring tools for postgreSql database



1.OPM
2.PGWATCH















steps to generate explain pla for sql in oracle DB?

EXPLAIN PLAN command

select plan_table_output   from table(dbms_xplan.display('plan_table',null,'basic'));

V$SQL_PLAN --last slq staement on cursor

select plan_table_output  from table(dbms_xplan.display_cursor(null,null,'basic'));

Automatic Workload Repository (AWR) 

1.note down the specific time
2.generate the awr for the specific  time
2.genarete the awr and pick the sql_id and genrate the explain plan
or
use dba_hist_sqlstat and get the sql_id and genrate the explain plan

SQL Tuning Set (STS)

SQL Plan Baseline (SPM)

--get the sql_handle from the query and generate the plan

 select SQL_HANDLE, PLAN_NAME, ACCEPTED   from dba_sql_plan_baselines
  where sql_text like 'select * from empty%';


select t.* from
table(dbms_xplan.display_sql_plan_baseline('SYS_SQL_1899bb9331ed0999',format => 'basic')) ;

Tuesday, September 1, 2015

steps to flush a particular sql statements from the database

get the SQL_ID for the SQl statement

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID like '81d%';

ADDRESS HASH_VALUE
---------------- ----------
<address> <hash value>

SQL> exec DBMS_SHARED_POOL.PURGE ('address, hash value', 'C');

PL/SQL procedure successfully completed.

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID like '81d%';
no rows selected.

Monday, August 24, 2015

queries used to check SQL cluster view status

check about sql cluster
-------------------------------
select serverproperty('ComputerNamePhysicalNetBIOS');

SELECT * FROM fn_virtualservernodes();

SELECT * FROM sys.dm_os_cluster_nodes ;

script to check the DG sync status from primary Database

set time on
set echo off
set verify off
set feedback off
set pagesize 999 lines 200
col dest_name for a40
col destination for a40
col applied_seq# for 999999999
col archived_seq# for 999999999
select dest_name,status,destination,archived_seq#,applied_seq#
from v$archive_dest_status
where status='VALID';

Monday, August 10, 2015

steps to change the oracle DB SAp user password.

Please use the below SYNTAX.

brconnect -c -p initTEST.sap -l E -f chpass -o SYSTEM -password <PASSWORD>

steps to do table level re-org in SAP oracle database?

1.check the table size before re-org
2.here is the syntax:
brspace -u / -c force -f  tbreorg -m online -a reorg -t <Table_name> -degree 4 -initial 2
3.check the table size after re-org it will be reduced.

Thursday, December 18, 2014

How to enable Query history on Netezza systems



Below are the sample steps that you can follow up to create and enable the history database:

1) Add users and grant appropriate access to them:

system(admin)=> create user owner with password 'ownerpw‘;
system(admin)=> grant create database to owner;
system(admin)=> create user audituser with password ‘audituserpw‘;
system(admin)=> grant list on audituser to owner;

2) Create history database using  “nzhistcreatedb” command:

$ nzhistcreatedb -d qhist -t q -u audituser -o owner -p 'ownerpw' -v 1

3) Maintenance of history database using  “nzhistcleanupdb” c- ommand:

$ nzhistcleanupdb -d qhist -u owner -pw 'ownerpw' –t ‘2011-10-31’

4) Create history configuration:

$ nzsql -c "CREATE HISTORY CONFIGURATION QUERY_HISTORY HISTTYPE QUERY NPS LOCALHOST DATABASE QHIST USER audituser PASSWORD 'audituserpw' COLLECT QUERY,PLAN,TABLE,COLUMN LOADINTERVAL 0 LOADMINTHRESHOLD 0 LOADMAXTHRESHOLD 1 STORAGELIMIT 10 LOADRETRY 1 ENABLEHIST TRUE ENABLESYSTEM TRUE VERSION 1;” VERSION 1;"

5) Enable history collection:

$ nzsql –c “SET HISTORY CONFIGURATION QUERY_HISTORY;”

6) Restart NPS using command:

$ nzstop;nzstart

Monday, December 15, 2014

How to do manual vac cum for Netezza database?

login as: root
root@server_name's password:
Last login: Thu Oct 30 17:35:29 2014 from xa65p020.domain.com
[root@server_name ~]# su - nz

     server_name NPS environment
==================================================

     HOME                 = /export/home/nz
     USER                 = nz

     NZ_USER              = admin
     NZ_DATABASE          = system


     /nz/data/config/system.cfg settings
==================================================

    startup.maxConnections    = 1000
    system.enableCTA2         = 1


[nz@server_name ~]$ date
Thu Oct 30 17:59:39 PDT 2014
[nz@server_name ~]$ nzrev
Release 7.0.2 (P-8) [Build 32960]
[nz@server_name ~]$ nzhw -issues
No entries found
[nz@server_name ~]$ nzds -issues
No entries found
[nz@server_name ~]$ nzds -regenstatus
No entries found
[nz@server_name ~]$ nzstats

Field Name           Value
-------------------- -------------------------------------------
Name                 server_name
Description          ddcnsdwodbcp01.domain.com
Contact            

Num SFIs             0
Num SPAs             2
Num SPUs             12
Num Data Slices      92
Num Hardware Issues  0
Num Dataslice Issues 0

[nz@server_name ~]$ nz_catalog_size > /tmp/nz_catalog_size_before.out
[nz@server_name ~]$ vi /tmp/nz_catalog_size_before.out
You have new mail in /var/spool/mail/nz
[nz@server_name ~]$ nzsession | grep -i active
1952508 sql      ADMIN        30-Oct-14, 18:02:16 PDT 10438 SYSTEM        active normal            127.0.0.1      10436 SELECT session_id, clien
[nz@server_name ~]$ /tmp/nz_catalog_size_before.out
[nz@server_name ~]$ ./nzverifysyscat -K /nz/kit -D /nz/data -P
-bash: ./nzverifysyscat: No such file or directory
[nz@server_name ~]$ cd /nz/kit/bin/adm/
[nz@server_name adm]$ ./nzverifysyscat -K /nz/kit -D /nz/data -P
        get database list
        verify syscat   IBM_NETEZZA_CUSTOMER_SERVICE
     
[nz@server_name adm]$ nzstate
System state is 'Online'.
[nz@server_name adm]$ nzstop
[nz@server_name adm]$ nzstate
System state is 'Stopped'.
[nz@server_name adm]$ nz_manual_vacuum

Confirmed that the database is stopped.

Creating a backup of /nz/data.  Please wait.

Backup completed.


#######################################################
#
# Database 1 of 12
#
# Vacuuming and Reindexing database 'IBM_NETEZZA_CUSTOMER_SERVICE'
#
#######################################################


NOTICE:  database system was shut down at 2014-10-30 18:09:47 PDT
NOTICE:  database system is in production state
DEBUG:  Session id is 16001

POSTGRES backend interactive interface
Revision: 7.1  Date: 2004/11/17 01:54:14

backend> DEBUG:  VACUUM: Opened all system relations
DEBUG:  VACUUM: vacuuming '_T_TYPE'
DEBUG:  Index _I_TYPE_OID: Pages 2; Tuples 37. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_TYPE_TYPNAME: Pages 2; Tuples 37. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_ATTRIBUTE'
DEBUG:  Index _I_ATTRIBUTE_RELID_ATTNAM: Pages 203; Tuples 10564: Deleted 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_ATTRIBUTE_RELID_ATTNUM: Pages 17; Tuples 10564: Deleted 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_CLASS'
DEBUG:  Index _I_CLASS_OID: Pages 2; Tuples 887: Deleted 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_CLASS_RELNAME: Pages 19; Tuples 887: Deleted 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_INHERITS'
DEBUG:  Index _I_INHERITS_RELID_SEQNO: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_INDEX'
DEBUG:  Index _I_INDEX_INDRELID: Pages 2; Tuples 98. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_INDEX_INDEXRELID: Pages 2; Tuples 98. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_STATISTIC'
DEBUG:  Index _I_STATISTIC_RELID_ATT: Pages 2; Tuples 304: Deleted 52. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_OPERATOR'
DEBUG:  Index _I_OPERATOR_OID: Pages 2; Tuples 664. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_OPERATOR_OPRNAME_L_R_K: Pages 15; Tuples 664. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_OPCLASS'
DEBUG:  Index _I_OPCLASS_OID: Pages 2; Tuples 32. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_OPCLASS_DEFTYPE: Pages 2; Tuples 32. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_OPCLASS_NAME: Pages 2; Tuples 32. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_AM'
DEBUG:  Index _I_AM_OID: Pages 2; Tuples 4. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_AM_NAME: Pages 2; Tuples 4. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_AMOP'
DEBUG:  Index _I_AMOP_OPID: Pages 2; Tuples 186. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_AMOP_STRATEGY: Pages 2; Tuples 186. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_AMPROC'
DEBUG:  VACUUM: vacuuming '_T_LANGUAGE'
DEBUG:  Index _I_LANGUAGE_NAME: Pages 2; Tuples 5. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_LANGUAGE_OID: Pages 2; Tuples 5. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_LARGEOBJECT'
DEBUG:  Index _I_LARGEOBJECT_LOID_PN: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_AGGREGATE'
DEBUG:  Index _I_AGGREGATE_NAME_NARG_TYPE: Pages 10; Tuples 193. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_AGGREGATE_OID: Pages 2; Tuples 193. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_IPL'
DEBUG:  VACUUM: vacuuming '_T_INHERITPROC'
DEBUG:  VACUUM: vacuuming '_T_REWRITE'
DEBUG:  Index _I_REWRITE_OID: Pages 2; Tuples 457. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_REWRITE_RULENAME: Pages 11; Tuples 457. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_LISTENER'
DEBUG:  Index _I_LISTENER_PID_RELNAME: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_DESCRIPTION'
DEBUG:  Index _I_DESCRIPTION_OBJOID: Pages 4; Tuples 1444. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_DIST_MAP'
DEBUG:  Index _I_DIST_MAP_SEQ: Pages 2; Tuples 15. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_DIST_MAP_RELID: Pages 2; Tuples 15. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_ORGANIZE_ON'
DEBUG:  VACUUM: vacuuming '_T_GROOM_HISTORY'
DEBUG:  VACUUM: vacuuming '_T_THIN'
DEBUG:  VACUUM: vacuuming '_T_ALTBASE'
DEBUG:  VACUUM: vacuuming '_T_ACTIONFRAG'
DEBUG:  Index _I_ACTIONFRAG_EVCLASS: Pages 2; Tuples 564. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_SELCACHE'
DEBUG:  VACUUM: vacuuming '_T_EXTERNAL'
DEBUG:  VACUUM: vacuuming '_T_EXTOBJECT'
DEBUG:  VACUUM: vacuuming '_T_EXTZONES'
DEBUG:  VACUUM: vacuuming '_T_CONSTRAINT'
DEBUG:  VACUUM: vacuuming '_T_CONST_RELATTR'
DEBUG:  VACUUM: vacuuming '_T_CONST_REFATTR'
DEBUG:  VACUUM: vacuuming '_T_SYNONYM'
DEBUG:  VACUUM: vacuuming '_T_BACKUP_GROUP'
DEBUG:  VACUUM: vacuuming '_T_BACKUP_GROUP_MEMBER'
DEBUG:  VACUUM: vacuuming '_T_RESTORE_ATTRESTOID'
DEBUG:  VACUUM: vacuuming '_T_LIBRARY'
DEBUG:  Index _I_LIBRARY_NAME: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_UDXATTRIBUTE'
DEBUG:  Index _I_UDXATTRIBUTE_RELID_ATTNAM: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_UDXATTRIBUTE_RELID_ATTNUM: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_SCSI_ERRORS'
DEBUG:  Index _I_SCSI_ERRORS_SCSI_ERRID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_SCSI_ERRORS_SCSI_HWID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_SPACOMP'
DEBUG:  VACUUM: vacuuming '_T_VT_HOSTTX'
DEBUG:  VACUUM: vacuuming '_T_MD_REGEN_ERRORS'
DEBUG:  Index _I_MD_REGEN_ERRORS_MD_ERRID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_MD_REGEN_ERRORS_MD_HWID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_MD_REGEN_ERRORS_MD_TBLID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_UDXENVIRONMENT'
DEBUG:  Index _I_UDXENVIRONMENT_RELID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_UDXENVIRONMENT_RELID_ATTNAM: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_TOAST_5150: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_ATTRDEF'
DEBUG:  Index _I_ATTRDEF_ADRELID: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_TOAST_1215: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  VACUUM: vacuuming '_T_PROC'
DEBUG:  Index _I_PROC_OID: Pages 4; Tuples 1418. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_PROC_PRONAME_NARG_TYPE: Pages 58; Tuples 1418. CPU 0.00s/0.00u sec.
DEBUG:  Index _I_TOAST_1255: Pages 1; Tuples 0. CPU 0.00s/0.00u sec.
DEBUG:  Analyzing...
DEBUG:  Analyzing...
DEBUG:  Analyzing...
DEBUG:  Analyzing...

backend> NOTICE:  shutting down
NOTICE:  database system is shut down

--------------------------------------------------------------------------------

NOTICE:  database system was shut down at 2014-10-30 18:09:50 PDT
NOTICE:  database system is in production state
DEBUG:  Session id is 16001

POSTGRES backend interactive interface
Revision: 7.1  Date: 2004/11/17 01:54:14

backend> NOTICE:  relation 1247 was reindexed
NOTICE:  relation 1249 was reindexed
NOTICE:  relation 1259 was reindexed
NOTICE:  relation 5107 was reindexed
NOTICE:  relation 5105 was reindexed
NOTICE:  relation 5115 was reindexed
NOTICE:  relation 5113 was reindexed
NOTICE:  relation 5112 was reindexed
NOTICE:  relation 5101 was reindexed
NOTICE:  relation 5102 was reindexed
NOTICE:  relation 5109 was reindexed
NOTICE:  relation 5110 was reindexed
NOTICE:  relation 5100 was reindexed
NOTICE:  relation 5114 was reindexed
NOTICE:  relation 5111 was reindexed
NOTICE:  relation 5104 was reindexed
NOTICE:  relation 5002 was reindexed
NOTICE:  relation 5030 was reindexed
NOTICE:  relation 5132 was reindexed
NOTICE:  relation 5146 was reindexed
NOTICE:  relation 5666 was reindexed
NOTICE:  relation 5727 was reindexed
NOTICE:  relation 5150 was reindexed
NOTICE:  relation 1215 was reindexed
NOTICE:  relation 1255 was reindexed

backend> NOTICE:  shutting down
NOTICE:  database system is shut down