728x90

Problem(Abstract)

This article tells you how to get a Null value(||) instead of a backslash (|\|) When you unload an empty varchar string.

Symptom

When executing SQL like below:

Example:
unload to x.unl select tabname, "" from systables where tabname = "tab1" 

The output file contains:
tab1|\ |

Cause

It is expected behavior as NULL cannot be represented by "", because IBM Informix considers this an empty string internally.

Resolving the problem

Use one of the following workarounds to get || instead of |\ | :


1) SELECT NULL::CHAR FROM table


or

2) SELECT CAST(NULL AS CHAR) FROM table



This simply defines the data type of the result set to return to the client.

Example:

unload to tab1.unl select tabname,CAST(NULL AS CHAR) from systables where tabid = 99;

1 row(s) unloaded.

> !cat t1.unl
VERSION||

or

> unload to t1.unl select tabname,NULL::CHAR from systables where tabid = 99;

1 row(s) unloaded.

> !cat tab1.unl

VERSION|| 


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

728x90
728x90


Problem(Abstract)

After installing the "Critical Patch Update October 2013 for Solaris 11" (ORACLE SOLARIS 11.1.12.5.0 REPO ISO IMAGE) on your Oracle Solaris 11 system your Informix Server instance may fail to start

Symptom

During the Informix instance start you will see following types of error messages in the instance message log and the instance will not come online:

13:23:26  Assert Failed: No Exception Handler
13:23:26  IBM Informix Dynamic Server Version 11.70.FC7W2
13:23:26   Who: Thread(134, kaio, 0, 16)
  File: mtex.c Line: 490
13:23:26   Results: Exception Caught. Type: MT_EX_OS, Context: mem
13:23:26   Action: Please notify IBM Informix Technical Support.
13:23:26   See Also: /tmp/af.46e0eae, shmem.46e0eae.0

The af.<xxxxxx> file will contain an empty stack trace of the kaio thread; the si_signo value of 11 will indicate the SEGV signal received by the oninit process:

13:23:26  Stack for thread: 134 kaio

 base: 0x0000000146f02000
  len:   69632
   pc: 0x0000000101103350
  tos: 0x00000001019ff751
state: running
   vp: 22

 ucontext: 0x0000000101a00a20
  siginfo: 0x0000000101a00d00
           si_signo: 11  si_code: 1   si_errno: 0 si_pid: 0 si_uid: 0
           si_addr: 0x0000000001057d68 si_value: 0x0000000000000000  si_fd: 0


Cause

One of the possible causes of the problem is following Oracle Solaris defect:


15815250 : SUNBT7197575 AUTOMOUNTD FAILS TO MOUNT LDAP USERS HOME DIR on SOLARIS 10 BRANDED

Resolving the problem

Contact the Oracle Solaris support and ask them for following fix:


IDR-fix idr781.1 for Solaris 11.1.8.4



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

728x90
728x90


Problem(Abstract)

How to unload rows from a table avoiding inaccessible data using the ROWID on data corruption scenarios.

Resolving the problem

INTRODUCTION

This document describes a technique that can help you rebuild a table based on the data that might be still accessible. It uses the concept of the ROWIDs and the UNLOAD command.

    Attention: This technique only saves rows that are still accessible. Damaged rows are lost.

    Note: The technique will not work for fragmented tables, because they do not have rowids.

STEPS

    1. Use the UNLOAD command to extract the accessible rows from the table. This command will fail when the first corrupted row is encountered:
    UNLOAD TO file1 SELECT rowid, * FROM table ;
    file1  
      File name where the data is going to the stored
    table
      Name of the source table
    2. Open file1 and take note of the last ROWID that was unloaded successfully:
    last_rowid = Last ROWID in file1
    3. Add two units to the last_rowid. You will use this value in the next step:
    next_rowid = last_rowid + 2
    4. Run the UNLOAD command again, this time to retrieve the remaining rows of the table using the next_rowid as the filtering argument:
    UNLOAD TO file2
    SELECT rowid, * FROM table where rowid >= next_rowid
    Note: If UNLOAD fails without producing any data, skip another rowid by increasing next_rowid. You might have to repeat steps 2, 3 and 4 many times depending on the quantity of corrupted rows. There are some scenarios where this technique can be very time-consuming.

    5. After unloading all possible rows, repeat steps 1 and 2, this time without selecting the rowid in the column list of the SELECT statement.
    UNLOAD TO file1 SELECT * FROM table ;
    UNLOAD TO file2
    SELECT * FROM table where rowid >= next_rowid
    6. Recreate the table using the data that was just unloaded.
      LOAD FROM file1 INSERT INTO table;
      LOAD FROM file2 INSERT INTO table;

Example:

    1. oncheck reported an error in the table customer. Run the first UNLOAD command until it fails.
      UNLOAD TO file1 SELECT rowid, * FROM customer;
    2. Suppose the last rowid found in the last record on file1 is decimal 1038:
    last_rowid = 1038
    3. Add two units to last_rowid :
    next_rowid = (last_rowid + 2) = 1040
    4. Using this calculation, restart the unload on rowid 1040:
      UNLOAD TO file2
      SELECT rowid, * FROM customer where rowid >= 1040;

    5. Repeat this process until you scan the whole table. Assuming that the second UNLOAD command finished without errors, the next step is to run the same commands again without the rowid.
      UNLOAD TO file1 SELECT * FROM customer;
      UNLOAD TO file2
      SELECT * FROM customer where rowid >=1040;

    6. Recreate the table and load the data using file1 and file2 as input files:
    LOAD from file1 insert into customer;
    LOAD from file2 insert into customer;


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

728x90
728x90

Problem(Abstract)

Randomly the following error shows up in the mesage.log of the Primary server of a HDR pair:



Needed to send a ping message but failed. 1

Symptom

Messages similar to the following will be displayed in the Message.log on Primary HDR server.

R: Needed to send a ping message but failed. 1
12:31:25 Logical Log 358 Complete, timestamp: 0x20c592c5.
12:31:27 DR: Needed to send a ping message but failed. 1
12:32:28 DR: Needed to send a ping message but failed. 1
12:33:11 Logical Log 359 Complete, timestamp: 0x20ca1170.
12:33:28 DR: Needed to send a ping message but failed. 1
12:33:59 DR: Needed to send a ping message but failed. 1
12:34:29 DR: Needed to send a ping message but failed. 1
12:35:06 Logi


Cause

This is strictly a new Warning message developed and released in IDS 11.70.xC7.

This message is displayed when the HDR buffer starts to backup and fill. This is usually evident of a very Busy system and no cause for alarm.

Monitor these Warnings. If the numeric value in the Warning message reaches a value of 3 or greater, possible Ping Time-out errors could start to occur.


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

728x90
728x90

Problem(Abstract)

Running ontape L 0 archive can fail with the following error

Archive failed - access sysmaster database (SQL:-404 ISAM:0)

Cause

Certain env variables set

Resolving the problem

determine if any of the following environment variables are set and unset them

  • IFX_AUTOFREE
  • IFX_DEFERRED_PREPARE
  • OPTOFC


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

728x90
728x90


Problem(Abstract)

KAIO is not enabled when chunks are created on raw devices. OS and related environment are no problems.

Cause

ls -l shows that the chunks are in the raw devices which are created as block devices by mistake.

ls -l
brw-rw---- 1 root system 22, 1 Aug 4 2012 rootchk
brw-rw---- 1 root system 22, 1 Aug 4 2012 llogchk
brw-rw---- 1 root system 22, 1 Aug 4 2012 plogchk
brw-rw---- 1 root system 22, 1 Aug 4 2012 datachk


The raw devices should be character devices.
crw-rw---- 1 root system 22, 1 Aug 4 2012 rootchk
crw-rw---- 1 root system 22, 1 Aug 4 2012 llogchk
crw-rw---- 1 root system 22, 1 Aug 4 2012 plogchk
crw-rw---- 1 root system 22, 1 Aug 4 2012 datachk

Resolving the problem

Change the devices to character devices with relative OS commands and restart Informix Server. Then KAIO will be enabled correctly.


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

728x90
728x90


Problem(Abstract)

The following query is to identify the 10 slowest SQL queries from syssqltrace. 

Note : SQLTRACE in $ONCONFIG need to be enabled in order to trace the SQL Queries.

Resolving the problem

To find the SQL Queries:

SELECT FIRST 10 * FROM sysmaster:syssqltrace  WHERE sql_runtime > 0  ORDER BY sql_runtime DESC; 

Then you can use the sql_id to query the sqltrace_iter tables to get the SQL statement iterators info. 

Syntax:
select * from sysmaster:syssqltrace_iter where sql_id = <sid> 

Example:
> select * from syssqltrace_iter where sql_id = 4; 

sql_id             4 
sql_address        504403159339495528 
sql_itr_address    504403159339512048 
sql_itr_id         1 
sql_itr_left       0 
sql_itr_right      0 
sql_itr_cost       9 
sql_itr_estrows    100 
sql_itr_numrows    1 
sql_itr_type       1 
sql_itr_misc       65672 
sql_itr_info       Seq Scan 
sql_itr_time       4.16157768e-05 
sql_itr_partnum    38 
sql_itr_sender     0 
sql_itr_nxtsender  0



728x90
728x90

데이터 정합성이 맞지않거나 통계정보 부정확등의 이유에 인해 dbexport로 추출된 데이터 건수가 실제 내려받은 데이터 건수와 다른 경우에 발생하는 오류 케이스입니다.


It might happen that the number of rows in the unload file does not match the number of rows in the

comment. In such cases the dbimport will fail.

dbimport often runs several hours and it is painful when it aborts after hours leaving a corrupted database.

Customers rely that a successful dbexport is usable for dbimport. Example: mstab00100.unl contains 5 rows instead of 3

(여기 예제에서는 실제로 데이터는 5건을 내려받았으나 메타정보로는 3건으로 표시하고 있습니다.)
{ TABLE "informix".mstab row size = 14 number of columns = 2
index size = 0 }
{ unload file name = mstab00100.unl number of rows = 3 }
create table "informix".mstab
  (
    id serial not null ,
    c1 char(10)
  );
revoke all on "informix".mstab from "public" as "informix";
Import data is corrupted! 
이 메시지는 실제로 데이터가 로케일이 다르거나 깨진 데이터로 인해 발생할 수도 있습니다.
또한 PK(Primary Key)에 의한 데이터 중복이 원인일 수 있습니다.
위의 결과는 데이터에 문제가 없더라도 데이터 건수 차이로 인한 오류메시지가 발생한 예 입니다.
Do you want to abort?y
This import is now invalid.
Calling dbimport with -c or continue although the number of rows is wrong is not an option
because the imported data might not be consistent.


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

728x90
728x90


Problem(Abstract)

When running a select query that contains COUNT(*) the following errors are returned:
> echo "select count(*) from customer;" | dbaccess stores_demo

Database selected.

252: Cannot get system information for table.

113: ISAM error: the file is locked.
Error in line 1
Near character position 61


Database closed.

Symptom

Errors -252/-113 are returned:

252: Cannot get system information for table.

113: ISAM error: the file is locked.

Cause

Isolation level Committed Read or Last Committed is used and there is an exclusive lock on the table

Diagnosing the problem

Using 'onstat -g sql' check the isolation level that sessions are using:

> onstat -g sql

IBM Informix Dynamic Server Version 11.70.FC3 -- on-Line -- Up 00:52:17 -- 182532 Kbytes

Sess SQL Current Iso Lock SQL ISAM F.E.
Id Stmt type Database Lvl Mode ERR ERR Vers Explain
39 - stores_demo CR Not Wait 0 0 9.24 Off
27 sysadmin DR Wait 5 0 0 - Off
26 sysadmin DR Wait 5 0 0 - Off
25 sysadmin DR Wait 5 0 0 - Off

In the above example session #39 is using an isolation level of Committed Read (CR).

Then check the table for exclusive locks. To do so, first get the partnum of the table. This can be done by running the 'oncheck -pt <dbname:tabname>' command:

> oncheck -pt stores_demo:customer

TBLspace Report for stores_demo:informix.customer

Physical Address 2:678
Creation date 08/05/2011 15:55:41
TBLspace Flags 802 Row Locking
TBLspace use 4 bit bit-maps
Maximum row size 134
Number of special columns 0
Number of keys 0
Number of extents 1
Current serial value 129
Current SERIAL8 value 1
Current BIGSERIAL value 1
Current REFID value 1
Pagesize (k) 2
First extent size 8
Next extent size 8
Number of pages allocated 8
Number of pages used 3
Number of data pages 2
Number of rows 28
Partition partnum 1049059
Partition lockid 1049059
<...>

Next, convert the partnum value into HEX: 1049059 = 0x1001e3

Finally, grep the partnum value (without the leading 0x) from 'onstat -k' output:

> onstat -k | grep 1001e3
4ebef028 0 4b85c418 4ebeed28 HDR+X 1001e3 102 0 D
4ebef328 0 4b85c418 4ebef228 HDR+X 1001e3 103 0 D
4ebef528 0 4b85c418 4ebef428 HDR+X 1001e3 104 0 D
4ebef728 0 4b85c418 4ebef628 HDR+X 1001e3 105 0 D
4ebef828 0 4b85c418 4ebeefa8 HDR+X 1001e3 106 0 D
4ebefa28 0 4b85c418 4ebef9a8 HDR+X 1001e3 107 0 D
4ebefb28 0 4b85c418 4ebefaa8 HDR+X 1001e3 108 0 D
4ebefd28 0 4b85c418 4ebefca8 HDR+X 1001e3 109 0 D
4ebeff28 0 4b85c418 4ebefea8 HDR+X 1001e3 10a 0 D
4ebf0128 0 4b85c418 4ebf00a8 HDR+X 1001e3 10b 0 D
4ebf0328 0 4b85c418 4ebf02a8 HDR+X 1001e3 10c 0 D
4ebf0528 0 4b85c418 4ebf04a8 HDR+X 1001e3 10d 0 D
4ebf0728 0 4b85c418 4ebf06a8 HDR+X 1001e3 10e 0 D
4ebf0928 0 4b85c418 4ebf08a8 HDR+X 1001e3 201 0 D
4ebf0b28 0 4b85c418 4ebf0aa8 HDR+X 1001e3 202 0 D
4ebf0ca8 0 4b85c418 4ebf0c28 HDR+X 1001e3 203 0 D
4ebf0ea8 0 4b85c418 4ebf0e28 HDR+X 1001e3 204 0 D
4ebf10a8 0 4b85c418 4ebf1028 HDR+X 1001e3 205 0 D
4ebf12a8 0 4b85c418 4ebf1228 HDR+X 1001e3 206 0 D
4ebf1428 0 4b85c418 4ebf13a8 HDR+X 1001e3 207 0 D
4ebf1628 0 4b85c418 4ebf15a8 HDR+X 1001e3 208 0 D
4ebf1828 0 4b85c418 4ebf17a8 HDR+X 1001e3 209 0 D
4ebf1a28 0 4b85c418 4ebf19a8 HDR+X 1001e3 20a 0 D
4ebf1c28 0 4b85c418 4ebf1ba8 HDR+X 1001e3 20b 0 D
4ebf1e28 0 4b85c418 4ebf1da8 HDR+X 1001e3 20c 0 D
4ebf2028 0 4b85c418 4ebf1fa8 HDR+X 1001e3 20d 0 D
4ebf2228 0 4b85c418 4ebf21a8 HDR+X 1001e3 20e 0 D
4ebfeda8 0 4b85c418 4ebfee28 HDR+X 1001e3 101 0 D
4ebfee28 0 4b85c418 44452788 HDR+IX 1001e3 0 0

In the above example, the table has an intent-exclusive lock on the whole table (HDR+IX) and some exclusive locks on its rows (HDR+X).

Resolving the problem

Set the isolation level to Dirty Read at the session level before running the query:

> echo "set isolation to dirty read; select count(*) from customer;" | dbaccess stores_demo

Database selected.

Isolation level set.


(count(*))

28

1 row(s) retrieved.

Database closed.

Another option is to set lock mode to wait in order to allow the query to wait until the lock is released:

> echo "set lock mode to wait; select count(*) from customer;" | dbaccess stores_demo


728x90
728x90

Question

How to increase performance by monitoring when the optimizer chooses to sequential scan a table instead of another alternative access method and then changing the table so that the optimizer selects the optimal method.

Answer

INTRODUCTION

In some circumstances small mistake in managing an IBM® Informix® Dynamic Server™ (IDS) can generate significant performance problems. A common mistake is to not monitor the number of sequential scans in an instance.

Often the Database Administrator (DBA) analysis the tables when they are created but does not continue to monitor their usage, so new users or new applications can query the tables using a different WHERE condition that is not optimized. This can generate sequential scans and in some circumstances can create significant performance problems. The sequential scan is the slowest way to query a table. 

An example is an update or a delete with WHERE conditions. If the table involved in this operation uses an index scan, the rows will be read directly and a lock will be put only on the rows or pages that satisfies the conditions. 

If the optimizer, instead of using an index scan, chooses to perform a sequential scan for the rows that satisfy the conditions, the following problems can arise:

  • Unnecessary pages are read from disk. This mean a lot of I/O operations, loss of hardware resources that can impacts the instance performance.
  • Increase in the number of locks used. If the table is very large and this operation is executed during the peak time, the lock requests can rise until the maximum limit allowed is reached. Other users that are executing operations in different tables will not be able to execute operations that request locks and they will receive an error message.

The most common reasons that can force the optimizer to choose a sequential scan instead of an index scan are listed below: 
  • Lack of appropriate indexes on large tables.
  • Statistics are missing or are not updated correctly using UPDATE STATISTICS.

The command onstat -p can be used to monitor the number of sequential scans that occurred in the instance check the value of " seqscans". If you discover that the number of sequential scans is quite high you need to do the following performance tuning activities: 
  • Query the partition table to identify which tables have a large amount of sequential scans.
  • Understand why the optimizer is not choosing an index scan when accessing those tables.

BEFORE YOU BEGIN

  • If TBLSPACE_STATS configuration parameter in your ONCONFIG is set to 0, the partition profiles is disabled then all columns in the sysptntab will contain the value 0, therefore the methods shown above will not return any useful info.
  • The command onstat -z will reset all the statistical information. If this command was executed recently this can generate false results.
  • When the database instance is started or restarted all the statistical information is reset.


STEPS

To find the name of the tables with a high number of sequential scans and to improve the performance you follow the following steps:

1. Query the partition table to find the tables with a high number of sequential scans

From dbaccess connect to sysmaster then execute the following select:

      SELECT  dbsname,tabname,b.partnum,pf_dskreads,pf_dskwrites,pf_seqscans
      FROM    systabnames as a, sysptntab as b
      WHERE   pf_seqscans > 200 AND a.partnum=b.partnum



This select will display only the tables that had more than 200 sequential scans performed since the database instance was started or since the last onstat -zwas executed. 

Example


dbsname       databasename
tabname       tablename
partnum       2097154
pf_dskreads   265432456
pf_dskwrites  543678954
pf_seqscans   34000



2. Check pf_dskreadspf_dskwrites, this number represents the number of pages read and write from the disk per table. If those numbers are low then it could mean that it is of no great importance to optimize the access method for this table. 

3. If pf_dskreadspf_dskwrites,are quite high then the DBA need to analyse the activity on this table. Try to discover which users are using this table and analyse the SQL statements that they have submitted. 
The command onstat -g sql 0 > file.out can help the DBA to obtain all the sql queries that are being executed in a particular moment. In version 7.x the command onstat -g sql 0 doesn't exist. However you can have the same result executing an awk script, for more information regarding awk look at the Related Information section at the bottom of this article.

4. once you have found the query that you think may generate a sequential scan you can use the sql command SET EXPLAIN on to obtain the path that the optimizer has chosen to execute the query. If the explain output shows a sequential scan try to improve the performance with one of the following actions:

  • Create the appropriate indexes for these queries.
  • Execute UPDATE STATISTICS (medium or high) for these tables. To generate the proper update statistics for your database, have a look at the Article Update statistics script. There is a link to the article at the end of this page.

Alternative methoin Unix or Linux only

The DBA can use a different approach that will avoid part of the activity in the sysmaster. The following command will read directly from the shared memory reducing the impact of the previous select on sysmaster:

1. Execute the following command from prompt:

onstat -g ppf|awk '{ if ($12 > 200) print }' -

where $12 is the twelfth columns that in 7.31, 9.40 and 10.00 represent the column "seqsc" that contain the number of sequential scans executed by the partition. Note that in other informix versions the position of this column "seqsc" can change.

2. Check “isrd” “iswrt” that represent the number of pages read and write related to this table. If those numbers are low it could mean that it is not important to optimize the sequential scan for this table.

3. Transform the partnum into decimal form. 

4. To find the name of the table, from dbaccess connect to sysmaster then execute the following select:


SELECT dbsname, tabname 
FROM systabnames 
WHERE partnum= xxxx    
</code>
where xxxx is the partnum transformed in decimal. 


5. once you have found the query that you think may generate a sequential scan you can use the sql command  SET EXPLAIN on to obtain the path that the optimizer has chosen to execute the query. If the explain output shows a sequential scan try to improve the performance with one of the following actions:

  • Create the appropriate indexes for these queries.
  • Execute UPDATE STATISTICS (medium or high) for these tables.



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

728x90

+ Recent posts