Professional Documents
Culture Documents
For UNIX
Chapter 1: Introduction
About This Guide ............................................................................ 1–1
Installation Requirements .................................................................... 1–4
About the Informix Database Driver ........................................................... 1–5
Contents iii
Chapter 5: Mapping MK to Informix
Introduction ................................................................................ 5–1
Table Naming Convention ................................................................... 5–2
Mapping Columns .......................................................................... 5–3
Mapping Indexes............................................................................ 5–4
Data Types ................................................................................. 5–6
Chapter 6: Tuning
Overview ................................................................................... 6–1
Testing Performance ......................................................................... 6–2
Adjusting Parameters ........................................................................ 6–3
Chapter 7: Troubleshooting
Overview ................................................................................... 7–1
Error Mapping and Reporting ................................................................ 7–2
Database Errors ............................................................................. 7–3
Tracing ..................................................................................... 7–6
Database Limitations ........................................................................ 7–7
Introduction
1
This guide describes the installation and maintenance of the Informix database
driver and provides guidelines for using MK in an Informix environment. This
guide does not provide information about Informix database administration or
database management. Refer to your Informix documentation for that
information.
Intended Audience
This guide is intended for system administrators and system programmers who
are responsible for installing and maintaining the Informix database, the
Informix database driver, and MK. Before using this guide, you should be
familiar with the following:
■ Operating system and common commands
■ System administration tools
■ Informix tools and RDBMS and Informix documentation
■ Structured Query Language (SQL)
■ MK concepts (such as users, companies, and so forth)
Introduction 1–1
About This Guide
Additional References
Introduction 1–3
Installation Requirements
Installation Requirements
You must install the Informix database before installing MK. Refer to the
Informix Installation Guide for information on installing the Informix database.
MK Shell
Database Driver
I-Record SQL
Informix
Database
Introduction 1–5
About the Informix Database Driver
Embedded SQL
The Informix driver uses Embedded SQL (also known as ESQL) to communicate
with the Informix database. ESQL embeds SQL statements into the Informix
driver host language, which is C. You can mix ESQL statements with other host
language statements, using the host variables to represent many of the database
manipulation elements. An important feature of ESQL is that it allows
generation of SQL statements at runtime. This is called dynamic SQL.
Dynamic SQL
Dynamic SQL is used to perform database actions. For example, when you
request an action to read, insert, or update a row, the database driver generates
an SQL statement and executes the statement with any input parameters.
If the execution is successful, the driver passes the results and requested data
back to MK. If the operation fails, an error code is generated and passed back to
MK.
Informix does its own disk management and does not use the UNIX file system.
Therefore, only Informix knows and manages its inner data structures and UNIX
is not aware of Informix structures. The basic units of internal data organization
are described in the following table:
Unit Description
pages A page is the basic unit of data access used by Informix.
The size of a page depends on the system hardware
configuration and is fixed for an installation.
extents The extent is a collection of physically contiguous pages
that contain data or index information for a single table.
tblspace The tblspace is a logical grouping of extents; it contains
information for a single table and its associated indexes.
chunks Chunks are a major unit of physical space. They are
either raw devices, parts of raw devices, or UNIX files.
Chunks reserve space for databases.
dbspaces A dbspace is a collection of chunks dedicated to the
storage of databases. A single dbspace can contain all
or part of one or more databases, each of which may
contain many tables and associated indexes.
blobspace A blobspace is composes of one or more chunks
dedicated to storing BLOB data types, such as byte and
text. Blobspaces are often used to store images and
multimedia application information.
Logging
The Informix driver creates all tables with logging, except for temporary tables,
which are created without logging.
Introduction 1–7
About the Informix Database Driver
Locking
The default isolation level, or the degree of concurrent data access, used by the
Informix driver during data retrieval is committed to read. For updates and
deletes, the row is locked exclusively until the end of the transaction.
Security
The Informix driver supports only MODE-ANSI databases (always created with
logging). In MODE-ANSI databases, when a table is created, no user other than
the table owner has any table privileges, unless explicitly granted. However, the
Informix driver provides the ability to organize users into groups. Each user can
have private tables and each group can have group tables. For private tables, no
user other than the table owner has any privileges on the table. For group tables,
the group is the table owner and all users within the group have all table
privileges.
For every group, a database is created with the same name as the group name.
All group tables for that group are created in this database. All private tables
belonging to users in the group are also created in the same database.
Informix does not allow you to grant table privileges on temporary tables.
Therefore, temporary tables cannot be used as group tables.
In addition to the files Informix requires, an MK installation uses several key files
to manage access to the database. The following table describes these files:
These files are discussed in more detail in Chapter 5, “Maintaining Driver Files.”
In addition, MK uses the files below to link tables to a particular database driver
and identify the communication protocol to be used between the shell and the
driver:
The following diagram illustrates how these files work with MK.
tabledef6.0
inf_users ipc_info
Informix inf_groups MK
Database inf_storage
Introduction 1–9
Chapter
Introduction
In general, installing MK in an Informix environment involves the following
steps:
1. Installing Informix database software
2. Configuring Informix for MK
3. Initializing the Informix database driver
4. Creating MK tables and companies
This chapter covers the first two steps and should be used with the information
found in the MK Installation and Upgrade Guide and in the Informix Installation
Guide. Step three is discussed in Chapter 3.
Use the following table to set the default values for Informix installation
parameters. You can change the parameter values by editing the ONCONFIG file
manually and restarting Informix.
Important! Do not run the Parameter-Initialize option after initializing the database
unless you are prepared to lose all current data.
After installing and working with MK, you may need to adjust some of these
parameters to fit the specific requirements of your environment.
Disk Requirements
If you have multiple disks, you can reduce input/output bottlenecks by careful
placement of the software. The following diagram illustrates some possible
configurations:
Disk 1 Disk 2
2 Disk
System MK Users
UNIX Data
Informix
UNIX Data
Users
Users
When Informix is initialized, the physical and logical logs reside in the root
dbspace. These logs should be moved to another dbspace before installing MK.
Create a separate dbspace for the physical and logical logs (for example, llogbds
and plogdbs), preferably on different devices and then move the logs to an
appropriate dbspace. This will enhance performance and provide better
safekeeping in case of media failure. Refer to the Informix Administrator's Guide
for more information.
Preparing UNIX
There are some UNIX steps that you must take to prepare the operating system
to receive Informix. These steps are:
1. Log in as root.
2. Set terminal erase key to Ctrl-h:
stty erase <ctrl>h
3. Add a new group called informix in the group file /etc/group with a group
ID greater than or equal to 100 but less than 300, and assign the user
informix to this group:
informix:*:150:informix
4. Create the Informix user for database administration.
5. Create the directory to contain the Informix database:
cd <directory specification>
mkdir informix
6. Assign the environment variables INFORMIXDIR and PATH to point to
this new directory.
Adjust kernel parameters, keeping the following in mind (parameter names may
vary depending on whether the kernel is System V or BSD):
■ SHMMAX*SHMSEG = how much shared memory Informix can use
■ SHMMAX*SHMMNI = how much shared memory in your UNIX system
■ SEMMNI*SEMMSL = how many semaphores Informix can access; these
values should reflect maximum number of Informix users
To prepare space for data storage, you can use either cooked files or raw devices.
The steps to do both are shown below.
Configuring Informix
⇒ To configure Informix:
1. Set up the following environment variables:
INFORMIXDIR
INFORMIXSERVER
Installing MK
After you prepare the Informix environment, you can install MK by running the
MK installation program, mk.install6.0. Refer to the MK Installation and Upgrade
Guide for complete instructions about the installation procedure.
This section summarizes the steps you need to take before installing the MK
Informix database driver:
1. Configure the installation.
2. Create a UNIX login for mk.
The user mk is the Database Administrator (DBA) of the database where
your MK tables are stored. Add mk to the bsp group at the UNIX level. For
example:
mk::125:125:<home directory>:/bin/ksh
■ For users root and bsp and any other users entered in the previous step,
grant resource permissions to the database:
grant resource to "root";
grant resource to "bsp";
grant resource to "user1";
grant resource to "user2"'
commit work;
Continue granting permission to all the Informix users for this database.
10. Change the owner and permissions on the file inf7_exec6.0 (this must be
done after MK is installed because the last step of the installation process
changes the file ownership to bsp).
chown root inf7_exec6.0
chmod 4750 inf7_exec6.0
11. Verify the file permissions you have set. The permissions should be:
-rwsr-x--- 1 root bsp (size) (date) inf7exec6.0
12. Add the user informix to the group informix in the file /etc/groups (if you
haven't already done so).
13. Exit the shell started by su.
exit
Introduction
After you install the Informix database and the Informix driver, you need to
modify certain MK data before you can begin using any Informix tables. You
need to:
■ Add Informix as a database in the Maintain Database Definitions
(ttaad4110m000) session.
■ Create at least one company with the Maintain Companies (ttaad1100m000)
session.
■ Link the company to the Informix database with the Assign Tables to
Databases (ttaad4111m000) session.
■ Run the Convert to Runtime Data Dictionary (ttaad4200m000) session.
After you have completed these steps, you can post data to the Informix
database.
Variable Description
SQLLOG Allows you to log various commands executed by the
driver in a trace file in the working directory of the user.
For more information, refer to Chapter 7,
"Troubleshooting."
INFPROF Allows you to profile database actions. Set to a number
of seconds. All SELECT sections taking longer than this
value are written to a file called infprof in the directory
where the driver was started. For more information,
refer to Chapter 6, "Tuning."
Make sure the company you want to create has been entered in the company
tables. If necessary, add the company.
2. If Informix has not been added already, add Informix as a database in the
Maintain Database Definitions (ttaad4110m000) session. Refer to the
previous section, Defining the Database in MK.
3. Run the Assign Tables to Databases (ttaad4111m000) session to specify that
the database for the company is Informix.
Overview
There are three files used to assign access privileges to MK driver users and to
link MK driver users to Informix databases:
■ inf_users (user file)
■ inf_groups (group file)
■ inf_storage (storage file)
These files reside in $BSE/lib/informix and can be created and maintained using
MK optimization sessions, the script inf7__admin6.0, or the executable
inf7_inst6.0.
This chapter describes the content and structure of these files. It also describes
how to use the database administration tools to maintain the files.
User File
The user file contains information about all MK users who can access Informix
tables. Each line in this file consists of four fields, which are separated by a colon
(:). The format is as follows:
For example:
bsp:bsp:ufFPd$d#Xyyp[95 bp]/*'*/<D/+]+L0:mk
Variable Value
MK user Name by which the user is known to MK. This
should be a valid login name and cannot be
Informix.
Informix user User name that is accessing the database. This is
usually the same as the MK user name.
Encrypted password User's encrypted password for the database. The
Informix driver does not use this password; therefore,
you do not need to assign one when creating a user
with the maintenance utility. The utility assigns a
dummy password.
Group name Group to which the user belongs—it is mk for all
users.
Note: Whenever you add or change user information, you must first do so in
the Informix database, and then use inf7_admin6.0 or the MK maintenance
sessions to modify the user file for the driver.
Group File
MK users are mapped to Informix databases or groups. Each group can have
many users. For every group, a database is created with the same name as the
group name. An MK Informix group is the same as an Informix database;
therefore, the group file contains information about Informix databases where
MK can find the Informix tables. This information is stored in
$BSE/lib/informix/inf_groups. Each line in this file is made up of two fields,
separated by a colon (:). The format is as follows:
Variable Value
Group name Group name should be mk.
Group password Group mk's encrypted password. This password is not used by
Informix; therefore, you don't have to assign one when creating a
user with the maintenance utility.
Storage File
The storage file contains information about the storage structure of the Informix
tables and specifies various object parameters. The Informix driver refers to this
file when creating objects and executing queries. The storage information is held
in $BSE/lib/informix/inf_storage. Each line in this file consists of seven fields,
separated by a colon (:). The format is as follows:
Note: Fields in square brackets [ ] are optional; you can use wildcards for the
table name and the company name.
Variable Value
User You can link table information to a specific user or several users by indicating
the user's login name in braces ({}). Specifications then apply to the defined
user only. Separate multiple users by a comma. If you do not specify a user,
the information applies to all users.
Table_name Specifies the name of the MK table. This is a combination of the package,
module, and table name. Available options are:
■ Wildcard (*) to specify all tables in all modules.
■ All tables in a module, specified by the five-letter package/module code
(tfacp, tdsls, and so forth).
■ Module code and specific table number (tiitm005, tccom001, and so
forth).
Company number Specifies the company number. Use a wildcard (*) to specify all companies or
you can one company or several companies separated by commas.
Entry type Indicates whether the line relates to a table or index:
■ Wildcard (*) to specify table and all indexes
■ Table only (T)
■ All indexes of the table (I)
■ One or more indexes of the table (In where n is the number of the index.
You can specify a list of indexes, separated by commas.
Owner type Specifies whether the table belongs to a single person or to a group. The
following options are available:
■ Private (the table can be accessed only by its owner)
■ Group (the table can be accessed by the entire group)
This relates only to tables; when used for an index, it is ignored.
Variable Value
Index optimization Specifies index optimization level. Specify 0 for no optimization; specify 1
for optimization using one hash column.
If you do not specify an optimization level for an index, the default is taken
from the corresponding table entry.
Refresh time By setting a refresh time (in seconds), you determine the validity period of a
table's data set. The default value is 0. You can set refresh time only for
tables; it is ignored for indexes.
Storage Specifies the parameters to be used when creating tables. See Defining Table
Storage Parameters later in this chapter for more information.
Examples
{acp}tiitm001:*:T:private:1:5:DBSPACE rootdb INITIAL 1024 LOCK row
{acp}tiitm001:000:I1,I2,I3::1::
*:*:I1,I2,I3::1::
For security reasons, only the Informix database administrator (informix) and
root are allowed to perform user administration tasks. This section describes the
basic user administration tasks. There are several tools available to perform
these tasks; these are described later in this chapter.
Adding a Group
At installation, the utility inf7_inst6.0 lets you add an initial group, dbspace,
database, and the users root and bsp. You can use the Informix tools onmonitor
and dbaccess to add dbspaces and databases, and inf7_admin6.0 to add users
and groups.
Dropping a Group
⇒ To drop a group:
1. Log in as informix or root.
2. Run inf7_admin6.0.
3. Drop the group using the Drop Group option under User Administration.
4. Verify using the List Groups option.
After dropping a group, you do not need to drop the group database. It is the
database administrator's decision whether to drop the database; however, you
should be extremely cautious about dropping the database since you might want
to save some of the data stored in that database. In general, it is best to keep the
database unless you experience security or disk space problems. If you do
decide to drop the database, use the following procedure:
1. Run ISQL using the Run ISQL option under Informix Maintenance.
2. Drop the database.
Multiple Specifications
When putting the table or index specifications in the storage file, be careful not to
create multiple specifications that refer to the same group table or index. For
example, if three MK users (alan, kent, bob) are in the group finance and the
storage file contains the following entries:
{alan}ttaad099:000:T:group:0:0:DBSPACE db1 LOCK row NEXT 128
{kent}ttaad099:000:T:group:1:0:DBSPACE db2 LOCK page NEXT 256
{bob}ttaad099:000:T:group:1:5:DBSPACE db3 NEXT 528
*:*:I::::
This file is valid from the syntax point of view; however, since alan, kent, and
bob are in the same group, they refer to the same group table with different
conflicting specifications. Because the specifications are different, this is what
might happen. If alan creates a table, the driver will create the table without
hash columns. If kent or bob attempt to access the table, the Informix driver will
assume that there is a single hash column and try to use it in the query. Since the
hash column does not exist, an error will be generated and kent and bob will not
be able to access the table.
You can avoid this problem by creating a common entry for all MK users in the
group. For example:
{alan,kent,bob}ttaad099:000:T:group:1:5:DBSPACE db1 LOCK row NEXT 256
Now there is only one set of specifications for the group table.
Parameters
When defining the storage structure, you can control various parameters for
creating tables. These parameters are optional and are specified using the
following syntax:
[INITIAL n] [NEXT n] [LOCK ( page/row )] [DBSPACE x] [TEMP]
Parameter
Keyword Description
INITIAL Specifies the size (in kilobytes) of the initial extent to be
created when creating the table. The minimum is 4 pages.
This parameter is used when creating the table and cannot be
changed later on. If not specified, the default is 8 pages.
NEXT Specifies the size (in kilobytes) of the next extent to be
allocated for the table. This parameter is used when creating
the table, but can be changed after the table is created. If not
specified, the default is 8 pages.
LOCK Specifies the lock mode to be used while accessing the table.
It can be either page or row. The default is row.
DBSPACE Specifies the name of the dbspace in which the table should
be created. If not specified, the table is created in the dbspace
containing the database.
TEMP Specifies that the table is a temporary table. If created, the
table exists only until the end of the session. Because
Informix does not allow you to grant permissions on
temporary tables, these tables cannot be created as group
tables.
Recommendations
When defining table storage and setting table parameters, keep the following
suggestions in mind:
■ For group objects (tables or indexes), create a single entry for all MK users in
the group. This will avoid conflicts and runtime errors.
■ For security reasons, limit write permission for the storage file.
■ Set index optimization to 1 (single hash column) unless the table is very
small or disk space is critical. Without hash optimization, the query time on
tables will increase.
■ Refresh time depends on how frequently the table data is modified. It
should create a balance between good performance and getting the most
recent data.
Unlike other parameters, which are used only during table creation, refresh
time is set every time the driver is started and when it accesses the table for
the first time. Therefore, after changing refresh time, if a driver is started,
new refresh times will be in effect.
■ If initial extent size and next extent size are not specified, Informix uses a
default of 8 pages. This may be too small for some tables, or tables that are
going to grow significantly in the future. In such cases, use the procedure
described in Appendix C to estimate the correct initial and next extent sizes,
then enter the values for the Initial and Next parameters.
■ Use the lock mode "row" for better concurrency. This is also the default used
by the driver, if none is specified. Lock mode "page" should be used only for
tables that are read-only or rarely modified.
■ If DBSPACE is not specified in the storage file, the table will be created in the
dbspace containing the database. Tables should not be created in the root
dbspace.
■ To change storage file entries after a table is created, use the Alter Table
Parameter option in inf7_admin6.0 (or drop and recreate the table).
Maintenance Tools
You can maintain the user, group, and storage files with a special administration
tool. Depending on the user interface you want to use, you can access different
versions of this tool. To maintain the driver files, you can use any of the
following:
■ MK Informix database maintenance sessions
■ inf7_admin6.0 tool
Note: Before adding groups or users with these tools, they must be defined as
valid UNIX and Informix users.
MK Sessions
From this menu, you can select the appropriate sessions for adding, removing,
and reporting user and group information and for editing and viewing the
storage file. You can also print Informix user, group, and storage information.
The maintenance tool, inf7_admin6.0, is a shell script that allows you to maintain
and report user and database information in Informix. Options in the script are
organized as follows:
Option Description
User Administration Options for adding or dropping MK Informix users
and groups
User Information Options for listing the contents of the user, group,
and storage files
Informix Information Options for displaying information about tables and
indexes in a database
Informix Maintenance Options for performing database management tasks
such as checking database catalogs, repairing
indexes, and changing table parameters
The inf7_admin6.0 script is stored in $BSE/bin. Before using this command, the
Informix database should be up and running. If it is installed and operational,
enter inf7_inst6.0 at the operating system prompt to access the Informix
maintenance command. (You are prompted for the BSE environment variable if
it is not already set.)
User Administration
The User Administration area allows you to maintain MK Informix users and
groups. You can select the operation you want to perform.
Option Description
Add user Adds the user to inf_users file and grants the user access to
all group tables. Enter the group and MK user name; this
user name is the same as the Informix user name. After
adding the user, grant resource privilege to the MK user for
the group database using Run ISQL.
Drop user Revokes all privileges to group tables for a user and
automatically deletes the user's line in inf_users. Enter the
MK user name and the group the user belongs to; you
cannot use wildcards. After removing the user, the DBA
should revoke the resource and the connect database level
permissions from the user.
Add group Enables you to create a group (database) by adding the
group to the inf_groups file. Enter the name of the group to
be created. The DBA should also:
■ Create a MODE ANSI database with group name
■ Grant DBA privileges to the group user
■ Grant connect permission to root user
Drop group Deletes a group from the inf_groups file. Enter the name of
the group to be dropped. If applicable, the DBA should
remove the group database and the corresponding UNIX
login.
Exit Exits the maintenance utility.
User Information
The User Information option lets you list the contents of the user file, the group
file, and the storage file. It also provides you with an option to edit the storage
file. You can select the operation you want to perform.
Option Description
List users Lists all users in the inf_users file. For each user, this option
displays the MK name, Informix name, and group.
List groups Lists all groups in the inf_groups file, including each group
name (database) along with a list of users in each group.
List storage Displays the information about a table or index held in the
inf_storage file.
Edit storage Allows you to edit the storage file.
Exit Exits the maintenance utility.
Informix Information
Option Description
Show tables Displays information about tables created in the current
created database. User name and table name are required. You can
also use wildcards.
Show table Shows column information for tables. User name and table
columns name are required. You can also use wildcards.
Show indexes Displays information about indexes on tables created by a
created user in the group. User name and table name are required.
You can also use wildcards. Update statistics is required to
show the latest information.
Show index Shows column information for indexes created by a user
columns (index owner). Since the user name and table name form
part of the index name, these are used to do a wild card
search for the index name. You can also specify an index
number if you want information about a specific index. If
you want to see all indexes created by the user of that table,
enter * for the index number.
Show table space Displays information about space used by tables in the
information database. User name and table name are required. You can
also use wildcards. Update statistics is required to show the
latest information.
Show database Displays the privileges assigned to various users in the
privileges current database. If the generic user public has a privilege,
that entry is highlighted with two asterisks (**).
Show dbspace Displays information about all dbspaces in Informix.
information
Exit Exits the maintenance utility.
Informix Maintenance
You can perform some common database management tasks by selecting the
Informix Maintenance option. Because there can be multiple databases, when
you select the Informix Maintenance option, you need to indicate the database
you want to maintain. Then you can select the option you want to perform. The
available options are described in the following table.
Option Description
Print report for a Prints indexes for a specific database or table within a
tablespace database. The Informix utility oncheck (oncheck -pt) is
used. User name and table name are required.
Print disk utilization Prints a disk utilization report. The Informix utility
report oncheck (oncheck -pt) is used. This report provides
detailed information about different types of pages
used in the table. User name and table name are
required.
Update statistics Updates statistics for tables in the current database.
User name and table name are required. Executing this
activity for a number of tables may take some time.
Run ISQL Runs Interactive SQL. ISQL will not run if Informix is
not up or you are using an unrecognized terminal type.
Note that ISQL is called dbaccess in recent versions of
Informix.
Show error message Displays the message associated with the specified
for SQL or ISAM code error code. Enter the absolute value of the error code.
For example, if the error code is -206, enter 206 to
display the corresponding message.
Alter table parameters Changes the next extent and lock mode for a table
owned by the user running inf7_admin6.0.
Exit Exits the maintenance utility.
Mapping MK to Informix
5
Mapping MK to Informix
5
Introduction
Before creating tables for MK, you should be familiar with certain MK
requirements. This chapter discusses the mapping between the MK database
dictionary and Informix. This mapping task is handled by the MK Informix
driver and involves:
■ Tables
■ Indexes
■ Columns
■ Data types
MK stores table columns and index information in its data dictionary. The
Informix driver uses this information for various database actions. However, the
Informix driver cannot use this information directly because fields in MK use
certain characters (such as the dot (.)) that are invalid for Informix and some data
types (such as date) are stored differently in MK and Informix.
In order to store and/or write the MK data, the driver maps the information into
a format suitable for Informix. All Informix database actions use this mapped
information.
To comply with MK table naming conventions, Informix table names use the
following naming format:
t<package code><data dictionary table name><3 digit company number>
For example, MK table name tiitm001 with company number 100 has the
corresponding Informix table ttiitm001100. Note that the company number
always contains three digits, using zeros if necessary.
Table Name MK
ttiitm001100 table prefix: t
package code: ti
table: itm001
company number: 100
ttdsls112100 table prefix: t
package code: td
table: sls112
company number: 100
Mapping Columns
Each MK data dictionary column has a corresponding Informix column. If an
MK column has a depth greater than one (array), each subsequent depth is a
separate Informix column.
Row ID is used as a pseudo column. It does not exist in the table, but is used
internally, so users will not be aware of its existence.
If a data dictionary field has a depth greater than one, each depth is a separate
Informix column and each Informix column is named using the corresponding
depth. For example, if the MK field ctod has depth 7, there are seven Informix
columns with names t_ctod_1, t_ctod_2, ...t_ctod_7.
Informix does not allow a period (.) as part of a column name. Therefore, if an
MK field name contains a period, the period is replaced by the underscore
character (_) in the corresponding Informix column name.
A hash column is created when a table has hash optimization. The hash column
name contains its corresponding index number. When single column index
optimization is used, there is a single hash column per index. The column name
is hash<index number> (for example, hash1, hash2). Thus, hash1 is created for
index 1, and hash2 for index 2.
Mapping Indexes
An Informix index name can contain up to 18 characters. The driver creates the
index name using package code, table name, company number, index number,
index order, and table owner name, according to the following example:
Index name = package code, such as ti
+ table name, such as itm001
+ company number, such as 100
+ index number, such as 2
+ table owner name
Note: If the table owner name is long, it is truncated so that
is does not exceed 18 characters.
Field Numbering
When an index is created, the field number associated with each field is stored in
memory as part of Informix's index information. If a field having a depth greater
than 1 is part of the index, Informix uses the following logic:
■ A field having a depth of n creates n columns in the Informix table. For
example, if field3 in the data dictionary has a depth of 3, it creates 3 fields in
Informix table — field 3, field 4, and field 5.
■ If this field is part of the index, the index description contains all the
corresponding Informix field numbers; in this example, 3, 4, and 5.
■ The index length includes the length of each of these fields.
When the index is created, for each field number, the corresponding field name is
picked up.
If an index consists of more than one field, the size of the hash column equals the
total of the sizes required for each field. For example, if the index consists of a
long field (size of 5) and a char field (size of 1), the column size is 6.
Index Ordering
Data Types
The following table shows the mapping between MK and Informix data types:
MK Informix
BDB_CHAR Short
BDB_ENUM
BDB_SHORT
BDB_LONG Long
BDB_MAIL
BDB_TIME
BDB_TEXT
BDB_BITSET
BDB_DATE Date
BDB_FLOAT Float4
BDB_DOUBLE Double
BDB_STRING CstringType
Dates
In MK, a date is stored as the number of days from the year 0001. Informix stores
dates as the number of days since December 31, 1899.
Converting from the MK date to the Informix date involves copying the day of
month, month, and year from MK (using the MK function) and passing these to
an Informix function that returns a corresponding Informix date. Converting
from Informix to MK follows the reverse path.
In MK, date 0 means that the date is not specified. In this case, minimum values
are used to create the Informix date:
day of month = month = year = 1
Strings
Tuning
6
Tuning 6–i
Chapter
Tuning
6
Overview
Tuning the database typically involves determining the requirements of your
environment and how data is being accessed, and then modifying data structures
as necessary. This chapter provides information to help you identify
performance bottlenecks, adjust initialization parameters, and manage the
database.
Tuning 6–1
Testing Performance
Testing Performance
To determine which table actions are time-consuming, you can set the INFPROF
environment variable to a number of seconds. All SELECT actions that take
longer than that are written to a file called infprof. This file lists information
such as the time for executing the cursor and retrieval of the result. The infprof
file is stored in the directory where the Informix driver was started.
You can specify the INFPROF variable in the tabledef6.0 file for a particular
table, as follows:
c
tiitm:*:informix(INFORMIXDIR=/darktools,INFPROF=0.0):N
In this example, the INFPROF variable is set to 0.4 seconds for the tables tdsls001
and zero seconds for all itm tables. If a SELECT takes more than 0.4 seconds for
table tdsls001, an entry is generated for the infprof file. For itm tables, all
SELECTS generate entries.
Note: If two tables have different INFPROF values, a separate driver is started
when the second table is accessed.
In the following from an INFPROF file, the number of seconds (profiling value)
is 0.00, indicated in the first row of the file.
98-4-01 [16:43:43]: Profiling value = 0.00 sec
Pid Table Owner I Mode Cache Exe Fetch Exe Fetch Tot
<12538> tiitm055000 bob 1 FIRST : - 0.02 0.09 - - 0.20
<12538> tiitm055000 bob 1 EQUAL : - 0.00 0.00 - - 0.08
<12538> tiitm055000 bob 1 EQUAL : 0.00 0.00
<12538> tiitm055000 bob 1 EQUAL : 0.00 0.00
<12538> tiitm055000 bob 1 NEXT : - 0.00 0.02 - - 0.10
<12538> tiitm055000 bob 1 NEXT : - - 0.00 - - 0.00
<12538> tiitm055000 bob 1 PREV : - 0.00 0.01 - - 0.09
<12538> tiitm055000 bob 1 PREV : - - 0.00 - - 0.00
<12538> tiitm055000 bob 6 FIRST : - 0.05 0.09 - - 0.15
Using the information in this file, you can determine when results are retrieved
from cache memory and how long it takes to fetch and execute various actions.
Adjusting Parameters
The most common way to tune the driver is by changing the values for the
following parameters:
■ Index optimization
■ Refresh time
Index Optimization
Index optimization involves managing the effects of the hash column, which has
a value obtained by combining all key field values using an algorithm. The
index is created on this column, instead of the conventional key fields. This
reduces search time since the index consists of a single column that maintains the
sort order of the components. You can indicate single level index optimization in
the storage file inf_storage to improve performance.
Refresh Time
Refresh time can be changed to control fetch optimization and caching. You can
set the refresh time in the storage file inf_storage.
Tuning 6–3
Chapter
Troubleshooting
7
Troubleshooting 7–i
Chapter
Troubleshooting
7
Overview
This chapter provides tips for troubleshooting in the MK Informix environment.
It includes information about database errors, tracing, and some of the
limitations of the Informix database.
Troubleshooting 7–1
Error Mapping and Reporting
You can also display the error message associated with any Informix error code
using the option Show Error Message for Informix SQL or ISAM Code or the
Show Error Message option in inf7_admin6.0.
The Informix driver also logs each error it encounters into a log file names
$BSE/log/log.informix. Use this file along with other log files to analyze any
errors encountered.
Database Errors
Refer to the following table for a description of database errors.
Troubleshooting 7–3
Database Errors
Troubleshooting 7–5
Tracing
Tracing
The MK Informix driver lets you trace various commands as they are executed
by the driver. You can control the information tracked through an environment
variable called SQLLOG. The information is stored in a trace file in your
working directory and is named sql.log. This file is useful for debugging and
monitoring low-level performance.
The following table lists the attributes that you can trace, and their SQLLOG
required value (numeric values are octal values).
Value Description
0001 Puts the user information into the trace file, including the database
user name, the user group, and other users in that group.
0002 Puts MK data dictionary information in the trace file for each table
accessed by the driver. This includes table column and index
information, number of hash columns, and refresh time.
0004 Each SQL statement that generates an error is logged in the trace file.
0010 All field values for the current record are put in the trace file.
0020 Each table action, such as create table (TCRTBL), is logged.
0040 Each database action, such as commit work (DCOM), is logged.
0100 Miscellaneous debug information is put in the trace file.
Database Limitations
There are some special characteristics of the Informix database that affect the
behavior of the MK Informix driver. In general, these characteristics involve
how Informix handles locking and updating tables.
Informix Locking
When a row is updated or deleted, it is locked until the end of the transaction.
Informix also locks the next and previous key value in the index. This can result
in some expected behavior. For example, consider a table with five rows, a
unique index, and a duplicate index (ascending).
Table
row1
row2 Process 1
index1
index2
row3
Process 2
row4
row5
If Process 1 reads row2 for an update using a unique index, row2 is locked. The
previous key value (row1) and the next key value (row3) are also locked. When
Process 2 attempts to read row1 for update using a unique index, Informix
allows the row to be read in spite of the lock; however, if Process 2 tries to delete
row1, the delete fails with "key locked" error. Although the read for update was
successful, the delete fails because the key was already locked by Process 1.
Consider the same table as describe above with a DUPLICATE index (index2)
and all rows with the same key values with respect to index2.
If Process 1 reads row4 for update using the duplicate index and deletes row4,
row4 is locked. But since all rows have the same key values, effectively, all rows
are now locked with respect to this key. If Process 2 attempts to read row1 for
update using the duplicate index, all rows for this index are locked; therefore, the
process fails with a "record locked" error.
Troubleshooting 7–7
Database Limitations
However, if Process 2 changes to the unique index and reads row1 for update,
the read will be successful. This is because all records have different key values
with respect to this index (since it is a unique index).
The above example assumes that there was no hash optimization. If the index
has hash optimization, the hash column has unique values even if the index is a
duplicate. So in this case, only the previous record is affected. Other records
having same key value have unique hash values and are not affected.
Read Isolation
By default, the MK Informix driver uses committed read isolation. You cannot
read a locked row using this isolation, so when MK issues a "read (without lock)"
request, the Informix driver changes the isolation to dirty read.
A dirty read can return a row that is being updated or inserted and not yet
committed. If the row is being updated, the dirty read returns the updated values
and not the original values. If a row is deleted, a dirty read will skip that row
even if the delete is not committed. This can lead to problems. For example:
■ If Process 1 deletes row2 and Process 2 reads first (row1) then read next, the
driver tries to read the next row using the default isolation, which is
committed read, and gets "locked" error.
■ The driver then changes the isolation to dirty read and tries to read again.
■ The dirty read skips the deleted row (row2) and returns row3.
Similarly, consider the case when Process 1 reads a row without locking; Process
2 updates the same row but does not do a commit, and then Process 1 issues a
ROW_CHANGED. The driver tries to read the same row using the default
committed read isolation and gets a locked error so it changes the isolation to
dirty read. In this case, dirty read returns updated values even though Process 2
has not done a commit yet.
Note: Some databases support read consistent transactions so that all queries on
the same object see the same data (taken at the start of the transaction. However,
Informix does not support read consistent transactions, so the command SET
TRANSACTION READONLY has no effect on the subsequent query.
Repeatable Reads
After reading a row for update, if the cursor is closed without doing the update,
the lock is released. This results in inconsistent behavior as another process can
now lock the row even though the first process has successfully read the row for
update. To prevent this, the Informix driver changes isolation level to repeatable
read before closing a cursor, if it was used to read a row for update. Now the
row remains locked even when cursor is closed.
Update Statistics
The Informix query optimizer uses the data generated by the SQL command
Update Statistics to determine query execution plan. However, table statistics
are only updated when you execute the Update Statistics statement using ISQL.
The Informix driver does not execute the Update Statistics statement at any time.
Note: For large tables, this process may take some time, so it should be done
when the load on the system is light.
If only a few tables in the database undergo modifications, update statistics can
be done for individual tables. If a large number of tables in a database are
modified, update statistics for database will be faster and will update all tables in
the database.
When a row is read for update, two locks are used. When the row is actually
deleted, Informix requires additional locks for key values in the index. If almost
all locks in an Informix system are already in use, it is possible that the delete
cannot get the required number of locks and will fail, giving the error "no more
locks." This situation may arise if heavy delete/insert/update activity is going
on concurrently.
In general, this is a rare condition, but if an installation frequently gets this error,
the DBA should increase the maximum number of locks in the Informix system
using the onmonitor utility.
Troubleshooting 7–9
Database Limitations
Unlike other databases, data definition statements like create table/index or drop
table/index are not single transactions in Informix. Thus, they need to be
explicitly committed. To present consistent interface to applications, the MK
Informix driver does a commit internally after executing such statements.
In Informix, there is no concept of a primary key. Thus, any index on table can
be dropped. However, the MK Informix driver prevents the dropping of the
primary (index1) index.
Executables
MK uses the following Informix executable files:
File Description
inf7_srv6.0 The Informix driver. Resides in $BSE/bin.
inf7_exec6.0 Auxiliary file used by the driver. Resides in $BSE/bin.
This executable should be owned by root and should have
the setuid bit on (permission 4750).
inf7_inst6.0 The script for installing the Informix driver, setting up the
initial database group, required users, and default table
specifications. Resides in $BSE/bin.
inf7_admin6.0 The shell script for administration. This script calls
inf7_maint6.0. Resides in $BSE/bin.
inf7_maint6.0 The program internally called by inf7_admin6.0 and
inf7_inst6.0 for doing various driver administration
functions, such as add user to group. Resides in $BSE/bin.
Driver Files
The following table lists the MK Informix driver files.
In this file, you identify the database used for the table, a host name for a remote
table, or a list of drivers and remote sites, separated by an ampersand ( & ). In
addition to specifying the database driver as Informix, you can use this file to
assign values for the following parameters:
Parameter Description
INFORMIXDIR Contains the full path name of the directory where the
Informix database is installed. If there are multiple
versions of Informix on your system, enter the name of the
directory containing the version you want to access.
When starting the Informix driver, the MK shell reads and
sets this environment variable so that the Informix driver
uses the corresponding database installation.
INFPROF Time for profiling SELECT statement execution time.
SQLLOG File for tracing various database actions.
Sample Entries
tiitm990:*:informix(INFORMIXDIR=/storm/informix,INFPROF=1):N
tiitm999:*:darkman:N
tiitm055:*:informix(INFORMIXDIR=/storm/informix)&ingres
(II_SYSTEM=/darktools)&viper:N
*:*:informix(INFORMIXDIR=/darktools/informix):N
In this example, table tiitm990 for all companies (*) is in the Informix database;
all tiitm999xxx tables are on the system darkman; and tiitm055xxx tables are
created in informix, ingres, and on the remote machine viper.
where:
■ driver_type — name of the driver recorded in tabledef6.0.
■ mode — drivers can operate in single(s) or multiple(m) client mode.
■ semaphore_key — key to be used for creating a semaphore.
■ message_key — key to be used for creating a message queue
■ protocol — type of the protocol used: socket (s), pipe (p), or message queue
(m).
■ path_name — full pathname of the driver executable file.
driver
operation mode
semaphore key
message key
protocol (s/m/p)
path of executable
For more information about defining databases and the ipc_info file, refer to the
MK System Administrator's Guide.
Introduction
When you create a table using Informix, you can indicate how much space you
want to reserve for that table. The create table statement allows you to specify
two parameters:
■ Ei — size of initial extent
■ En — size of each additional extent
Specifying extent sizes is optional. Default for both is 8 pages. However, if you
use the default extent size for a large table, you may exceed the maximum
number of extents allowed per tblspace, which causes an out-of-space error.
If performance is the main criterion, you must create extents large enough to
handle any contingency. But this may result in inefficient utilization of disk
space. If disk space is critical, estimate the exact storage.
Informix provides the facility of changing the size of any additional extent (En),
by using the alter table statement. The alter table statement does not, however,
affect existing extents (including the one currently being written on). It only
affects extents created after issuing the statement.
The MK Informix driver also provides the facility of specifying the initial and
next extent sizes for a table. You can use the maintenance utility inf7_admin6.0
or the MK Informix utilities sessions to alter the next extent size of an existing
table.
General Overhead
The exact amount of space lost to overhead is subject to several factors, making it
difficult to derive a precise formula for general overhead. Use these guidelines
to make an initial estimate:
■ Determine total row length, page space to be used, and how many rows can
fit on a page
■ Determine the total index length
■ Add 25% to cover the overhead for index tree structure
Index overhead can vary substantially (either higher or lower) from the 25%
guideline, depending on how packed the b-trees are from deletion and insertion.
Row Requirements
Rows require space for both columns and indexes. The row length is the sum of
the lengths of the individual columns for that row. The index length is the sum
of index entries of all indexes for that table. The length of a single index entry is
the length of the key plus eight bytes to store a pointer to the corresponding row.
After determining the size of each row, you should estimate how many rows are
going to be present in the table:
■ Estimate the number of rows you want to store initially.
■ Use this estimate to determine the size of initial extent (Ei).
■ Estimate the table growth for a reasonable period of time and divide the
space needed for additional rows by seven (the number of additional extents
that Informix can directly access without using additional overhead).
■ Use this estimate to set the size of next extent (En).
When a table has hash optimization, additional hash columns are created
internally. Their size should be taken into account for calculating the row size.
Also, indexes are actually created on hash columns instead of original table
column s; therefore, the index space requirement also changes.
Note: You can use the MK maintenance tools to obtain the row size and index
sizes for existing tables. This information can be used to alter the next extent size
of a table.
Sample
Basic Requirements:
■ Index 1: order_num
■ Index 2: stock_num, manu_code
■ Initial rows: 20,000
■ Additional rows: 35,000
■ Assume page length: 2048
Steps:
1. Determine each index length and add 8 bytes:
index 1 = 4 + 8 = 12
index 2 = 2 + 3 + 8 = 13
3. Increase by 25%:
Index + overhead = 25 * 1.25 = 31.3
7. Determine system page length and subtract 32 to get usable page length:
Corrected page length = 2048 -32 = 2016 bytes
9. Divide the page size by the row length and round down:
Number of rows per page = 2016 / 18 = 112
10. Divide the number of rows by the number of rows per page:
Number of data pages = 20,0000 / 112 = 178.6 = 179