Sponsored Content
Top Forums Programming DB2 - Performance Issue using MERGE option Post 303018330 by Perlbaby on Monday 4th of June 2018 05:39:54 AM
Old 06-04-2018
DB2 - Performance Issue using MERGE option

Dear Team,
I am using DB2 v10.5 and trying to load huge data using MERGE option ( 10-12 Million) using below query. Basically it loads data from staging to target . Staging table schemaname.Customer_Staging has 12 Million records . Runs for 25 Mins for just select query. But while doing merge (first time load) , it has to insert all records and below process is getting hanged after running 1.5-2 hrs (With No inserts)


HTML Code:
   MERGE INTO schemaname.Customer_Table A
    USING ( SELECT DISTINCT B.Name , B.CUST_ID, B.ORG_ID from schemaname.Customer_Staging B 
    WHERE (B.Name is not null and length(B.Name)>0) and (B.CUST_ID is not null and length(B.CUST_ID)>0) and (B.ORG_ID is NOT null and length(B.ORG_ID) > 0)) B
     ON B.Name = A.Name and B.CUST_ID=A.CUST_ID and B.ORG_ID=A.ORG_ID and A.Load_dt is null
    WHEN NOT MATCHED THEN INSERT (Name,CUST_ID,Load_dt,ORG_ID)  
    VALUES(B.Name,B.CUST_ID,current timestamp - current timeZone,B.ORG_ID);

DDL columns for both staging and Target is same .
Included Unique index for three columns Name,CUST_ID,ORG_ID using
Code:
ALLOW REVERSE SCANS PAGE SPLIT SYMMETRIC option


Please can someone help how to tweak this query or use best approach.
any help appreciated
Thanks
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Performance issue

Hello all, I just stuck up in an uncertain situation related to network performance... I am trying to access one of my remote client unix machine from a distant location.. The client machine is Ultra-5_10 , with SunOS 5.5.1 The ndd result ( hme1 )shows that the machine is hooked to a... (5 Replies)
Discussion started by: shibz
5 Replies

2. Shell Programming and Scripting

DB2 Connect issue

Hi i m trying to connect DB2 via unix. it is successfully connect. but the connect is getting disconnect . below is the query , countvalue=$(db2 "connect to <Database> user <username> using <Password>" | db2 -x 'select count(*) from <tablename>' ); echo $countvalue while... (2 Replies)
Discussion started by: baskivs
2 Replies

3. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

4. Shell Programming and Scripting

issue with grep -B option

hi friends, i have a file where every word is present in a new line for example: more file1: i want to fetch previous line wherever i am getting "as" as a keyword. i tried at home the follwing code in linex: grep -B 1 "as" file1 ouput: caste caste1 it was working!! but now i am... (6 Replies)
Discussion started by: neelmani
6 Replies

5. Shell Programming and Scripting

/db2home full issue in db2

Hi all, I am new for linux environment, and i am working as a DBA. I am facing some issues in OS level: In our dev boxes /db2home under this directory i'm not finding any folder but it's showing 98% used . /dev/dm-14 5.0G 4.6G 115M 98% /db2home # ls -lrt total 16... (1 Reply)
Discussion started by: suresh_target
1 Replies

6. Shell Programming and Scripting

Issue on executing db2 queries through shell script

hi i am trying to execute db2 queries through shell script. it's working fine but for few queries is not working ( those queries are taking time so the script is not waiting to get the complete the execution of that query ) could you please any one help me on this is there any wait... (1 Reply)
Discussion started by: bhaskar v
1 Replies

7. Shell Programming and Scripting

UNIX with DB2 error status Issue

I have a shell script main.ksh We are calling dbscript.ksh from main.ksh I am using select statement in dbscript.ksh but there is a problem with the select statement in dbscript.ksh but still echo $? is showing as zero. I am using DB2 commands in dbscript.ksh Main.ksh dbscript.ksh echo $? ... (13 Replies)
Discussion started by: vamsi.valiveti
13 Replies

8. Programming

DB2 - Determine Cost Savings in USD - After performance Tuning

Dear Team Have this interesting question on how to determine cost savings(USD) based on performance tuning in Db2 I am using DB2 v10.5 . I worked on db2 procedure that loaded 20Million records in just 2 Mins. ETL execution time reduced from 30 Mins to 2 Mins. From 15 Hrs Monthly to 1... (2 Replies)
Discussion started by: Perlbaby
2 Replies

9. Shell Programming and Scripting

Best performance to merge two files

Hi Gurus, I need to merge two files. file1 (small file, only one line) this is first linefile2 (large file) abc def ghi ... I use below command to merge the file, since the file2 is really large file, the command read whole file2, the performance is not good. cat file1 > file3... (7 Replies)
Discussion started by: green_k
7 Replies
INSERT(7)							   SQL Commands 							 INSERT(7)

NAME
       INSERT - create new rows in a table

SYNOPSIS
       INSERT INTO table [ ( column [, ...] ) ]
	   { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }
	   [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

DESCRIPTION
       INSERT  inserts new rows into a table.  One can insert one or more rows specified by value expressions, or zero or more rows resulting from
       a query.

       The target column names can be listed in any order. If no list of column names is given at all, the default is all the columns of the table
       in  their  declared order; or the first N column names, if there are only N columns supplied by the VALUES clause or query. The values sup-
       plied by the VALUES clause or query are associated with the explicit or implicit column list left-to-right.

       Each column not present in the explicit or implicit column list will be filled with a default value, either its declared default  value	or
       null if there is none.

       If the expression for any column is not of the correct data type, automatic type conversion will be attempted.

       The  optional  RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted.  This is primarily useful
       for obtaining values that were supplied by defaults, such as a serial sequence number. However, any expression using the table's columns is
       allowed. The syntax of the RETURNING list is identical to that of the output list of SELECT.

       You  must have INSERT privilege on a table in order to insert into it. If a column list is specified, you only need INSERT privilege on the
       listed columns.	Use of the RETURNING clause requires SELECT privilege on all columns mentioned in RETURNING.  If you use the query  clause
       to insert rows from a query, you of course need to have SELECT privilege on any table or column used in the query.

PARAMETERS
       table  The name (optionally schema-qualified) of an existing table.

       column The name of a column in table.  The column name can be qualified with a subfield name or array subscript, if needed. (Inserting into
	      only some fields of a composite column leaves the other fields null.)

       DEFAULT VALUES
	      All columns will be filled with their default values.

       expression
	      An expression or value to assign to the corresponding column.

       DEFAULT
	      The corresponding column will be filled with its default value.

       query  A query (SELECT statement) that supplies the rows to be inserted. Refer to the SELECT [select(7)] statement for a description of the
	      syntax.

       output_expression
	      An  expression to be computed and returned by the INSERT command after each row is inserted. The expression can use any column names
	      of the table.  Write * to return all columns of the inserted row(s).

       output_name
	      A name to use for a returned column.

OUTPUTS
       On successful completion, an INSERT command returns a command tag of the form

       INSERT oid count

       The count is the number of rows inserted. If count is exactly one, and the target table has OIDs, then oid  is  the  OID  assigned  to  the
       inserted row. Otherwise oid is zero.

       If the INSERT command contains a RETURNING clause, the result will be similar to that of a SELECT statement containing the columns and val-
       ues defined in the RETURNING list, computed over the row(s) inserted by the command.

EXAMPLES
       Insert a single row into table films:

       INSERT INTO films VALUES
	   ('UA502', 'Bananas', 105, '1971-07-13', 'Comedy', '82 minutes');

       In this example, the len column is omitted and therefore it will have the default value:

       INSERT INTO films (code, title, did, date_prod, kind)
	   VALUES ('T_601', 'Yojimbo', 106, '1961-06-16', 'Drama');

       This example uses the DEFAULT clause for the date columns rather than specifying a value:

       INSERT INTO films VALUES
	   ('UA502', 'Bananas', 105, DEFAULT, 'Comedy', '82 minutes');
       INSERT INTO films (code, title, did, date_prod, kind)
	   VALUES ('T_601', 'Yojimbo', 106, DEFAULT, 'Drama');

       To insert a row consisting entirely of default values:

       INSERT INTO films DEFAULT VALUES;

       To insert multiple rows using the multirow VALUES syntax:

       INSERT INTO films (code, title, did, date_prod, kind) VALUES
	   ('B6717', 'Tampopo', 110, '1985-02-10', 'Comedy'),
	   ('HG120', 'The Dinner Game', 140, DEFAULT, 'Comedy');

       This example inserts some rows into table films from a table tmp_films with the same column layout as films:

       INSERT INTO films SELECT * FROM tmp_films WHERE date_prod < '2004-05-07';

       This example inserts into array columns:

       -- Create an empty 3x3 gameboard for noughts-and-crosses
       INSERT INTO tictactoe (game, board[1:3][1:3])
	   VALUES (1, '{{" "," "," "},{" "," "," "},{" "," "," "}}');
       -- The subscripts in the above example aren't really needed
       INSERT INTO tictactoe (game, board)
	   VALUES (2, '{{X," "," "},{" ",O," "},{" ",X," "}}');

       Insert a single row into table distributors, returning the sequence number generated by the DEFAULT clause:

       INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets')
	  RETURNING did;

COMPATIBILITY
       INSERT conforms to the SQL standard, except that the RETURNING clause is a PostgreSQL extension. Also, the case in which a column name list
       is omitted, but not all the columns are filled from the VALUES clause or query, is disallowed by the standard.

       Possible limitations of the query clause are documented under SELECT [select(7)].

SQL - Language Statements					    2010-05-14								 INSERT(7)
All times are GMT -4. The time now is 09:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy