728x90

Question

How to identify a resource contention?

Answer

Two new onstat commands introduced in 12.10.xC2 to view the dependencies between blocking and waiting threads. A running threads take ownership of various objects and resources; for example, buffers, locks, mutexes, decision support memory etc. Contention for these resources among hundreds or thousands of threads can result in chains of dependencies.

Now, you can use the 'onstat -g bth' command to display the dependencies between blocking and waiting threads. Next, use the 'onstat -g BTH' command to display session and stack information for the blocking threads.

Here is a scenario where these onstat commands can be helpful. It possible a thread that is blocked waiting to enter a critical section might own a row lock for which another thread is waiting. The second thread might be blocking a third thread that is waiting in the MGM query queue. Usually, the duration of such contention is short and user never notice any problem. However, if a thread is blocked long enough, you might need to identify the source of the contention. The 'onstat -g bth' command discovers the chains of dependency and displays blocker threads followed by waiting threads, in order.

The following is a sample output of the 'onstat -g bth' command where multiple threads are waiting on resources.

Highest level blocker(s)
 tid      name                 session
 48       sqlexec              26

Threads waiting on resources
 tid      name                 blocking resource              blocker
 49       sqlexec              MGM                            48
 13       readahead_0          Condition (ReadAhead)           -
 50       sqlexec              Lock (0x4411e578)              49
 51       sqlexec              Lock (0x4411e578)              49
 52       sqlexec              Lock (0x4411e578)              49
 53       sqlexec              Lock (0x4411e578)              49
 57       bf_priosweep()       Condition (bp_cond)             -
 58       scan_1.0             Condition (await_MC1)           -
 59       scan_1.0             Condition (await_MC1)           -

In the above example, four threads are waiting for a lock that is owned by thread 49. However, that's not the actual problem. The thread 49 is waiting for MGM resources that are owned by thread 48. So, originally problem started with the thread 48. Next, run the 'onstat -g BTH' command to see the session and stack information of thread 48. Following is the example for 'onstat -g BTH' output:

Stack for thread: 48 sqlexec
 base: 0x00000000461a3000
  len:   69632
   pc: 0x00000000017b32c3
  tos: 0x00000000461b2e30
state: ready
   vp: 1

0x00000000017b32c3 (oninit) yield_processor_svp
0x00000000017bca6c (oninit) mt_wait
0x00000000019d4e5c (oninit) net_buf_get
0x00000000019585bf (oninit) recvsocket
0x00000000019d1759 (oninit) tlRecv
0x00000000019ce62d (oninit) slSQIrecv
0x00000000019c43ed (oninit) pfRecv
0x00000000019b2580 (oninit) asfRecv
0x000000000193db2a (oninit) ASF_Call
0x0000000000c855dd (oninit) asf_recv
0x0000000000c8573c (oninit) _iread
0x0000000000c835cc (oninit) _igetint
0x0000000000c72a9e (oninit) sqmain
0x000000000194bb38 (oninit) listen_verify
0x000000000194ab8a (oninit) spawn_thread
0x0000000001817de3 (oninit) th_init_initgls
0x00000000017d3135 (oninit) startup



Highest level blocker(s)
 tid      name                 session
 48       sqlexec              26      

session          effective                  #RSAM    total   used   dynamic
id      user     user  tty   pid   hostname threads  memory  memory explain
26      informix -     45    31041 darwin   2        212992  186568 off

Program :
/usr/informix/bin/dbaccess

tid      name     rstcb            flags    curstk   status
48       sqlexec  448bc5e8         ---P---  4560     ready-
58       scan_1.0 448bb478         Y------  896      cond wait  await_MC1 -

Memory pools    count 2
name         class addr          totalsize  freesize   #allocfrag #freefrag
26           V     45fcc040      208896     25616      189        16        
26*O0        V     462ad040      4096       808        1          1        

name           free      used           name           free       used      
overhead       0         6576           mtmisc         0          72        
resident       0         72             scb            0          240      
opentable      0         7608           filetable      0          1376      
log            0         33072          temprec        0          17744    
blob           0         856            keys           0          176      
ralloc         0         55344          gentcb         0          2240      
ostcb          0         2992           sqscb          0          21280    
sql            0         11880          xchg_desc      0          1528      
xchg_port      0         1144           xchg_packet    0          440      
xchg_group     0         104            xchg_priv      0          336      
hashfiletab    0         1144           osenv          0          2520      
sqtcb          0         15872          fragman        0          1024      
shmblklist     0         416            sqlj           0          72        
rsam_seqscan   0         368            

sqscb info
scb              sqscb          optofc   pdqpriority optcompind  directives
4499c1c0         461c1028       0        100         2           1        

Sess       SQL          Current       Iso Lock       SQL  ISAM F.E.
Id         Stmt type    Database      Lvl Mode       ERR  ERR  Vers  Explain    
26         SELECT       stores        CR  Not Wait   0    0    9.24  Off        

Current statement name : unlcur

Current SQL statement (5) :
  select * from systables,syscolumns,sysfragments

Last parsed SQL statement :
  select * from systables,syscolumns,sysfragments

 

http://www-01.ibm.com/support/docview.wss?uid=swg21654372&myns=swgimgmt&mynp=OCSSGU8G&mync=E

728x90
728x90

 

Problem(Abstract)

You may noticed a difference in amount of memory usage between 'onstat -g seg' and 'onstat -g mem' command outputs. For example; the virtual portion of memory in 'onstat -g seg' is showing about 4GB of memory used, but total of all the memory pools shown by 'onstat -g mem' is only about 1GB in virtual pools.

Cause

You cannot directly compare 'onstat -g seg' with 'onstat -g mem' for virtual memory usage. The 'onstat -g mem' output provides only memory pool information where as the virtual portion of shared memory for the database server includes the following components:

  • Large buffers, which are used for large read and write I/O operations
  • Sort-space pools
  • Active thread-control blocks, stacks, and heaps
  • User-session data
  • Caches for SQL statements, data-dictionary information, and user-defined routines
  • A global pool for network-interface message buffers and other information

 

http://www-01.ibm.com/support/docview.wss?uid=swg21655248&myns=swgimgmt&mynp=OCSSGU8G&mync=E

728x90
728x90

Question

How to rename chunks of current instance using external restore.

Answer

1) onmode -c block
2) copy the existing chunk to the new one
3) onmode -ky
4) ontape -p -e rename -f filename

    or
ontape -p -e -rename -p old_path -o old_offset -n new_path -o new_offset

728x90
728x90


Question

How can you use a SQL statement to find out the latest UPDATE STATISTICS HIGH and UPDATE STATISTICS MEDIUM commands that were run on a table?

Answer

INTRODUCTION

You can use a SQL statement to obtain information regarding each of the most recent UPDATE STATISTICS HIGH and UPDATE STATISTICS MEDIUM commands that ran against a table.

The type of information you can obtain from the most recent update statistics is the following:

  • The date on which it ran
  • The mode used (high or medium)
  • The column(s) it ran against
  • The resolution used
  • The confidence level used


STEPS 

You can run this SELECT statement from any application: 

    SELECT UNIQUE tabname,colname,constructed,mode, 
           resolution,confidence 
    FROM  systable s t, syscolumns c, sysdistrib d 
    WHERE d.tabid = c.tabi d  AND d.colno = c.colno A ND 
           d.tabid = t.tabid AND 
           t.tabname=' tablename ' 
    ORDER BY 1,2;

    tablename
      The name of the table you want the distribution information for.


The SELECT statement will output columns. The following table indicates their meaning: 

Column
Description
tabname
The name of the table
colname
The name of the particular column in the table that the distribution had ran.
constructed
The date when the UPDATE STATISTICS statement had ran. (The date of construction of the data distribution.)
mode
What mode the UPDATE STATISTICS used.

H = HIGH
M = MEDIUM

There will never be an L because UPDATE STATISTICS LOW does not construct a data distribution.
resolution
The resolution used by the UPDATE STATISTICS statement
confidence
The confidence level used by the UPDATE STATISTICS statement

    Note: The confidence level for distributions run in high mode is irrelevant so it should always be set to zero.

Example: 

This example shows that UPDATE STATISTICS was last run on 8 July 2003. The column named  code of the table named  state had its distribution updated in High mode. It used a resolution of .5. The mode was high so there is no confidence level. 

The column named  sname in the same table had its distribution built in medium mode. It used a resolution of 2.5 and a confidence level of approximately 0.95. 

    tabname      state 
    colname      code 
    constructed  07/08/2003 
    mode         H 
    resolution   0.5 
    confidence   0.00 

    tabname      state 
    colname      sname 
    constructed  07/08/2003 
    mode         M 
    resolution   2.500000000000 
    confidence   0.94999999

You can also find this information from the UNIX or Windows command line using the dbschema utility (see Related Information section). 


COMMON PROBLEMS 

Symptom: You run the SELECT previously mentioned and you see this message   
    No rows found is returned.


Resolution: It means the table does not have data distribution. You can run the UPDATE STATISTICS command for the table to generate the data distribution.


http://www-01.ibm.com/support/docview.wss?uid=swg21154913

728x90
728x90


Problem(Abstract)

How to retrieve when and for which columns the distributions were last built.

Resolving the problem

INTRODUCTION

This article shows a SQL statement which can be executed to retrieve when and for which columns the distributions were last built. However, if a column does not have a distribution it will not appear in the query output.


STEPS

select systables.tabname, syscolumns.colname, 
      sysdistrib.constructed,mode
from sysdistrib,systables,syscolumns
where systables.tabid > 99
and systables.tabid = syscolumns.tabid
and sysdistrib.tabid=systables.tabid
and sysdistrib.colno = syscolumns.colno
group by 1,2,3,4
order by tabname,colname;


Example

Assuming that 

    UPDATE STATISTICS HIGH for table customer (customer_num) 
was run, what follows is the corresponding information returned by the query for the table customer
     
    tabname      customer 
    colname      customer_num 
    constructed  12/15/2006 
    mode         H 


http://www-01.ibm.com/support/docview.wss?uid=swg21251926

728x90
728x90


Question

Forcing a named index to be used as the index associated with a primary key or a foreign key. Here is how.

Cause

System generated names for primary and foreign key indexes and constraints.

Answer

There are times that you may want to specify the name of the index associated with a foreign key constraint or a primary key constraint rather than having one generated by the engine. You may, for instance, want to use the index name as part of an optimizer directive to be used on the same table in more than one instance.

To specify a name for the index associated with a primary key constraint or a foreign key constraint do the following:

    1. Create the table without including the PRIMARY KEY or FOREIGN KEY clause. 

    2. Create a unique index on the columns used by the primary key or foreign key you want to create. This index will be the one that will be used by your primary key or foreign key constraint. 

      Example: 

      If you are going to create a primary key on the columns col1 and col2 of a table named tab2 and you want the index to be named ixtab2 you would use this statement to create the index: 
        CREATE UNIQUE INDEX ixtab2 on tab2(col1,col2);


    3. Alter the table to add the primary key or foreign key constraint. The engine will detect that a unique index already exists on the columns and use that index automatically.


      Example: 

      Continuing the previous example, the following ALTER TABLE statement would create primary key constraint that uses the index ixtab2: 
        ALTER TABLE tab2 ADD CONSTRAINT PRIMARY KEY(col1,col2);

If you place both a primary key constraint and a foreign key constraint on the same columns of a table then both constraints will use the same index. 



http://www-01.ibm.com/support/docview.wss?uid=swg21108831

728x90
728x90

* SP_AUTOEXPAND 가 0일때 (onstat -d에서 DBSPACE 다섯번쨰 플래그 없음)

1. chunk extendable (onstat -d에서 청크 다섯번째 플래그 'E') 상태이더라도 자동으로 청크가 확장되지 않음

2. 수동으로 chunk extend 명령을 수행할 수 있음

e.g. execute function task("modify chunk extend",4,"10000");



* SP_AUTOEXPAND 가 1일때,(onstat -d에서 DBSPACE 다섯번쨰 플래그 'A') 

1. chunk extendable (onstat -d에서 청크 다섯번째 플래그 'E') 상태일 때 자동으로 청크가 확장됨

2. 기본적으로 sysmater:sysdbstab의 extend_size 값에 따라 증가하는 것으로 보임 (기본값 create_size 10, extend_size 10000)

3. 대체로 기본값인 10MB 씩 증가하지만 꼭 10MB씩 일정하게 증가하는 것은 아님,

extend_size를 10000으로 설정하고 100MB 데이터를 지속적으로 로드했을 때, 

10,000KB - 16,384KB - 32,768KB - 65,536KB 순으로 증가하는 크기가 늘어남

(다른 사이트의 예나 인포센터를 참조했을 때 create_size, extend_size는 최소 증가 사이즈.

더 크게 증가하는 경우는 내부적으로나 매뉴얼에 명시된 계산식이 있는 듯함)



http://www.ibm.com/developerworks/data/library/techarticle/dm-1103storageprovisioning/#expanding

https://www.ibm.com/developerworks/community/blogs/informix_admins_blog/entry/expandable_chunks_in_informix_11_701?lang=en

728x90
728x90

Question

You are using an IBM Informix Server. You want to determine the edition of product that you have installed.

Answer

Your INFORMIXDIR will have a subdirectory with the name "license" or "ids_license." Find the file in the license subdirectory that is appropriate for the language you use. Open the file and search for the program edition statement. For example, in the English language file, a search on "Edition" yields a line like the following:

Program Name: IBM Informix Ultimate Edition V11.70

In this case you have a fixpak of IBM Informix Server 11.70 installed and it is Ultimate Edition.


http://www-01.ibm.com/support/docview.wss?uid=swg21642781&myns=swgimgmt&mynp=OCSSGU8G&mync=E

728x90
728x90

Question

What is the recommended way of running UPDATE STATISTICS in a database so that the optimizer will have the information it needs to run the most efficiently? This article includes a utility to produce an SQL command file that runs all of the UPDATE STATISTICS command recommended for a particular database.

Answer

You can make sure that the optimizer has all of the data it needs to make your queries more efficient by running the SQL command UPDATE STATISTICS on your database. 

    1. Run UPDATE STATISTICS LOW on all tables in the database. 

    2. Run UPDATE STATISTICS MEDIUM on all columns which are in an index, but are not the first column of any index. 

    3. Run UPDATE STATISTICS HIGH on all columns which are the first column in an index. 

    4. Run UPDATE STATISTICS on all stored procedures.

This should be done any time that there are significant changes made to the distribution of the data. 

To make the task of running all of these UPDATE STATISTICS statements easier you could put them into a single SQL command file. 


makeupdate.sql 

Here is a command file named makeupdate.sql that can be used to generate an SQL command file that runs the recommended UPDATE STATISTICS commands for your particular database. 

To use the makeupdate.sql script follow these steps: 
    1. Copy the file makeupdate.sql.txt to a working directory and change the name to makeupdate.sql

      makeupdate.sql.txt

    2. Run the makeupdate.sql command file using dbaccess.

      Example: 

      If your database is named mydb and the makeupdate.sql command file is in your current directory then you can run it by entering this at the command line:

        dbaccess mydb makeupdate.sql

The SQL commands in makeupdate.sql produce an SQL command file named update_stats.sql in the current directory. 

To complete the UPDATE STATISTICS process you must run this SQL command file using dbaccess. 

    Example: 

    If your database is named mydb and the update_stats.sql command file is in your current directory then you can run it by entering this at the command line:
      dbaccess mydb update_stats.sql

You may also consider the Auto Update Statistics (AUS) maintenance system available in IBM™ Informix Dynamic Server version 11.50 and later. Refer to the topic "Automatic statistics updating" in the System Administration section of the Informix 11.50 information center (see Related URL section)


출처:

http://www.ibm.com/support/docview.wss

728x90
728x90

Question

This article provided details of how to write an awk script that can collect information about all active SQL sessions running on an IBM® Informix® Dynamic Server 7.31 database.

Answer

INTRODUCTION

IBM® Informix® Dynamic Server (IDS) version 9.x introduced the ability to collect information for all active SQL sessions by using the command onstat -g sql 0. This functionality can be replicated for IDS version 7.31 databases by using the following awk script.

STEPS

Create an awk script that contains the following text:

BEGIN {system(":> onstat_g_sql_0")}
{
if ($NF > 0) {
my_string= onstat -g sql " $1 "  >> onstat_g_sql_0; echo \"----------------\" >> onstat_g_sql_0"
system(sprintf(my_string))
}
}
END {}


Note: This script directs the SQL information to a file called onstat_g_sql_0 in the current working directory. 

Run this script using the command 

onstat -g sql|tail +6|awk -f <scriptname> 

where scriptname is the name of the awk file created in the previous step. To improve usability, this command could be written as a shell script (with execute permissions) and located in a directory referenced by your PATH environment variable. 

Display the contents of the output file to view the details of all the sql in execution in the database. 

Example 

SQL running on database server
IBM Informix Dynamic Server Version 7.31.UD8     -- on-Line -- Up 00:10:54 -- 8912 Kbytes
Sess  SQL            Current            Iso Lock       SQL  ISAM F.E.
Id    Stmt type      Database           Lvl Mode       ERR  ERR  Vers
13    SELECT         informix_log       CR  Not Wait   0    0    7.31
11    -              informix_log       CR  Not Wait   0    0    7.31


Sample output from awk script

IBM Informix Dynamic Server Version 7.31.UD8     -- on-Line -- Up 00:10:20 -- 8912 Kbytes
Sess  SQL            Current            Iso Lock       SQL  ISAM F.E.
Id    Stmt type      Database           Lvl Mode       ERR  ERR  Vers
13    SELECT         informix_log       CR  Not Wait   0    0    7.31
Current statement name : slctcur
Current SQL statement :
  select * from test2
Last parsed SQL statement :
  select * from test2
----------------
IBM Informix Dynamic Server Version 7.31.UD8     -- on-Line -- Up 00:10:20 -- 8912 Kbytes
Sess  SQL            Current            Iso Lock       SQL  ISAM F.E.
Id    Stmt type      Database           Lvl Mode       ERR  ERR  Vers
11    -              informix_log       CR  Not Wait   0    0    7.31
Last parsed SQL statement :
  UPDATE   test2 set str1="bbb" where key=0
----------------


http://www-01.ibm.com/support/docview.wss?

728x90

+ Recent posts