Local client communicates with UDB server using shared memory and semaphores.
Remote client communicates using protocol such as NPIPE, TCP/IP, NetBIOS, and SNA.
On the server side, communication and data transfer activity is performed by Engine
Dispatchable Unit (EDU). EDUs are shown as circle or group of circles in above diagram. It runs
as a process on UNIX.
A set of sub agents is assigned to particular client application request. Multiple sub agents can be
assigned if the machine where server resides has multiple processors or is part of partitioned
database. All agents and sub agents are managed using pooling algorithm that minimizes the
creation and destruction of EDUs.
Database Shared Memory (also known as Database Global Memory) is allocated when a
database is activated or connected to for the first time. This memory is used across all
applications that might connect to the database. Database Shared Memory can be controlled by
the database_memory configuration parameter.
Many different memory areas are contained in database shared memory including:
Buffer pools
Lock list
Database heap - and this includes the log buffer .
Utility heap
Package cache
Catalog cache
Application shared memory (also known as application global memory) is allocated when an
application connects to a database only in a partitioned database environment, or in a non-
partitioned database with intra-parallelism enabled, or if the connection concentrator is enabled.
This memory is used by agents that do the work requested by clients connected to the database.
Agent/local application shared memory. This memory is used for SQL request and response
communications between an agent and its client application.
DB2 Table spaces
Single table space can span several containers. Container is made of data pages. Number of
pages that the database writes to container before using different container is called extent size.
Table space management
Buffer pool are areas of database server memory where database pages of user table data, index
data and catalog data are temporarily moved and can be modified.
Data can be accesses much faster from buffer pool than from disk. Adequate buffer pool size
improves performance by reducing I/O and carrying out most of the work in memory.
Default IBMDEFAULTBP buffer pool is created which is shared by all table spaces. More buffer
pool can be added later of different size.
LONG VARCHAR, BLOB, CLOB data types are directly referred from disk using non-buffered IO.
Table space can only be associated with one Buffer pool but one Buffer pool can be used for
more than one table space.
Page size of the buffer pool should be same or grater than Page size of table space associated
with it. Default Buffer pool page size is 4KB. The size can be 8KB, 16KB, and 32KB etc.
Unique Index
DB2® uses unique indexes to ensure that no identical key values are stored in a table.
When you create a table that contains a primary key, you must create a unique index for that
table on the primary key. DB2 marks the table as unavailable until the explicit creation of the
required indexes. You cannot define a foreign key unless the corresponding primary key already
exists and has a unique index defined on it.
Clustered Indexes
In Clustered indexes order of the rows in the table is in the same physical order as the desired
result set. Clustered indexes allow for a more linear access pattern to data pages and more
effective pre fetching, and help avoid sorts. It leads to longer inserts, but quicker selects.
Tips for Cluster Index
- Do not create clustered indexes on volatile tables as the index will not be used.
- For best performance, create the index over small data types (like integer and char(10)),
unique columns, and columns most often used in range searches.
- Increasing free space on data and index pages to about 15-35 (instead of the default 10
for PCTFREE) for high volumes of inserts.
- For heavily insert Tables, use a single dimension MDC table (perhaps using a generated
column like idcolumn/1000 or INT (date)/100). This will cause the data to be block
indexed (on the dimension) rather than on the row. The resulting index is smaller and log
contention is significantly reduced during insert.
Use ALLOW REVERSE SCANS to allow for an index to be scanned bi-directionally, which
means quicker retrieval of ascending and descending result sets. This has no negative
performance impact since the index structure does not change internally to support this feature.
INCLUDE can be used to include additional non-indexed columns in the index page to promote
index-only access and avoid data page fetches.
TYPE-2 INDEXES drastically reduce next-key locking, allow for index columns greater than 255
bytes by default, allow for both online REORG and RUNSTATS, and support the new
multidimensional clustering ability. All new indexes in v8 will be created as type-2 except when
there was already a (pre-migration) type-1 index defined on the table. Use REORG INDEXES to
convert type-1 to type-2 indexes.
The isolation level associated with an application process defines the degree of isolation of that
application process from other concurrently executing application processes. The isolation level
of an application process therefore specifies:
The degree to which the rows read and updated by the application are available to
other concurrently executing application processes.
The degree to which the update activity of other concurrently executing application
processes can affect the application.
Depending on the type of lock, this limits or prevents access to the data by concurrent application
processes. (Declared temporary tables and their rows cannot be locked because they are only
accessible to the application that declared them.)
Locking occurs at the base table row. The database manager, however, can replace multiple row
locks with a single table lock. This is called lock escalation.
The DB2(R) Universal Database database manager supports four isolation levels. Regardless of
the isolation level, the database manager places exclusive locks on every row that is inserted,
updated, or deleted. Thus, all isolation levels ensure that any row that is changed by this
application process during a unit of work is not changed by any other application processes until
the unit of work is complete.
REBIND
After performing a REORG and RUNSTATS, you will want to REBIND all database packages so
that their static SQL can take advantage of the most recent system stat.
Performance Improvement
http://www.ibm.com/developerworks/data/library/techarticle/dm-0404mcarthur/
MDC
http://www.ibm.com/developerworks/data/library/techarticle/dm-0404mcarthur/
Partitioning
http://www.ibm.com/developerworks/data/library/techarticle/dm-0404mcarthur/
Diff between Oracle and DB2 and Teradata
Storage Physical Block -> Data File Data Page -> Container
Tablespaces Locally Managed SMS
Bigfile DMS
Temporary
Default (SYSTEM, SYSAUX) (Catalog, Temp, System) SMS
Indexes Unique Unique
Non-unique Non unique
Partitioning Clustering
Function based
Bit map
Optimizer Rules bases Cost based
Cost based