to get the best optimizer execution plan, collecting detailed table statisitics might help:
db2 -x -r "runstats.db2" "select rtrim(concat('runstats on table ',concat(rtrim(tabSchema),concat('.',concat(rtrim(tabname),' on all columns with distribution on all columns and sampled detailed indexes all allow write access'))))) from syscat.tables where type='T'"
db2 -v -f "runstats.db2"
Showing posts with label DB2. Show all posts
Showing posts with label DB2. Show all posts
Tuesday, April 14, 2009
Tuesday, April 7, 2009
DB2 : Generating SQL Explain plan
This is how explain plan can be generated in DB2 database.
Create a file statements.db2:
select deptno from dept@
db2expln -database U001DB -stmtfile statements.db2 -terminator @ -terminal -user siebel siebel
Section Code Page = 1252
Estimated Cost = 30087412.000000
Estimated Cardinality = 19275950.000000
Access Table Name = SIEBEL.S_ORG_EXT ID = 7,201
| #Columns = 2
| Relation Scan
| | Prefetch: Eligible
| Lock Intents
| | Table: Intent Share
| | Row : Next Key Share
| Sargable Predicate(s)
| | Process Build Table for Hash Join
Left Outer Hash Join
| Early Out: Single Match Per Outer Row
| Estimated Build Size: 7776000
| Estimated Probe Size: 9948879872
| Access Table Name = SIEBEL.S_ORG_EXT ID = 7,201
| | #Columns = 2
| | Relation Scan
| | | Prefetch: Eligible
...
...
Create a file statements.db2:
select deptno from dept@
db2expln -database U001DB -stmtfile statements.db2 -terminator @ -terminal -user siebel siebel
Section Code Page = 1252
Estimated Cost = 30087412.000000
Estimated Cardinality = 19275950.000000
Access Table Name = SIEBEL.S_ORG_EXT ID = 7,201
| #Columns = 2
| Relation Scan
| | Prefetch: Eligible
| Lock Intents
| | Table: Intent Share
| | Row : Next Key Share
| Sargable Predicate(s)
| | Process Build Table for Hash Join
Left Outer Hash Join
| Early Out: Single Match Per Outer Row
| Estimated Build Size: 7776000
| Estimated Probe Size: 9948879872
| Access Table Name = SIEBEL.S_ORG_EXT ID = 7,201
| | #Columns = 2
| | Relation Scan
| | | Prefetch: Eligible
...
...
Sunday, April 5, 2009
DB2 : Establish remote connection on Unix/AIX
On server hosting DB2 Database:
db2set DB2COMM=tcpip
update database manager configuration using svcename 50000
db2stop
db2start
On client server (with DB2 client installed)
db2 UNCATALOG DATABASE U001DB
db2 UNCATALOG DCS DATABASE U001DB
db2 UNCATALOG NODE SERVER1
db2 CATALOG TCPIP NODE SERVER1 REMOTE SERVER1 SERVER 50000 REMOTE_INSTANCE DB2 SYSTEM SERVER1 OSTYPE AIX
db2 CATALOG DCS DATABASE U001DB AS U001DB
db2 CATALOG DATABASE U001DB AS U001DB AT NODE SERVER1 AUTHENTICATION DCS
Where, SERVER1 is the server where db2 server resides. U001DB is the db2 database name.
Test connection:
On client server:
db2 connect to U001DB user siebel using siebel
Database Connection Information
Database server = DB2/AIX64 9.1.6
SQL authorization ID = SIEBEL
Local database alias = U001DB
db2set DB2COMM=tcpip
update database manager configuration using svcename 50000
db2stop
db2start
On client server (with DB2 client installed)
db2 UNCATALOG DATABASE U001DB
db2 UNCATALOG DCS DATABASE U001DB
db2 UNCATALOG NODE SERVER1
db2 CATALOG TCPIP NODE SERVER1 REMOTE SERVER1 SERVER 50000 REMOTE_INSTANCE DB2 SYSTEM SERVER1 OSTYPE AIX
db2 CATALOG DCS DATABASE U001DB AS U001DB
db2 CATALOG DATABASE U001DB AS U001DB AT NODE SERVER1 AUTHENTICATION DCS
Where, SERVER1 is the server where db2 server resides. U001DB is the db2 database name.
Test connection:
On client server:
db2 connect to U001DB user siebel using siebel
Database Connection Information
Database server = DB2/AIX64 9.1.6
SQL authorization ID = SIEBEL
Local database alias = U001DB
Subscribe to:
Posts (Atom)