473,224 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Poor insert performance

I was trying to copy a range of records from a table to the same table
with a small modification. I was wondering why this takes a long time
compared to just doing a subselect from that table and insert to a new
table (without constraints). Could it be a problem with the constraints
checking capability or the index maintenance? The subselect itself
takes a small time, so that will not be the problem...

Before executing the query I tried to set the constraints checking off
by the following statements; but it doesn't work as I expected:

SET INTEGRITY FOR DB2INST1.ASSPC OFF
SET INTEGRITY FOR DB2INST1.ASSPCACT OFF
SET INTEGRITY FOR DB2INST1.ASSPCACTSIBLING OFF

Any suggestions are welcome...

Regards, Peter

TABLE:
======

CREATE TABLE "DB2INST1"."ASSPC" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY ( START WITH +1
INCREMENT BY +1 MINVALUE +1 MAXVALUE +2147483647 NO CYCLE NO CACHE
NO ORDER ),
"VERSIONID" INTEGER NOT NULL WITH DEFAULT 1,
"ASSVS_ID" INTEGER NOT NULL,
"ASSVS_VERSIONID" INTEGER NOT NULL,
"VS_PC_ID" INTEGER NOT NULL,
"VS_PC_VERSIONID" INTEGER NOT NULL,
"CREATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP,
"DELETE" TIMESTAMP,
"UPDATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP,
"MULTIFAC" DECIMAL(4,1)
) IN "USERSPACE1" ;
PRIMARY KEY:
============

ALTER TABLE "DB2INST1"."ASSPC"
ADD CONSTRAINT "CC1084276791058" PRIMARY KEY ("ID", "VERSIONID");

FOREIGN KEYS:
=============

ALTER TABLE "DB2INST1"."ASSPC"
ADD CONSTRAINT "CC1084276820350" FOREIGN KEY ("ASSVS_ID",
"ASSVS_VERSIONID")
REFERENCES "DB2INST1"."ASSVS" ("ID", "VERSIONID")
ON DELETE RESTRICT
ON UPDATE RESTRICT
NOT ENFORCED
ENABLE QUERY OPTIMIZATION;

ALTER TABLE "DB2INST1"."ASSPC"
ADD CONSTRAINT "CC1084276849722" FOREIGN KEY ("VS_PC_ID",
"VS_PC_VERSIONID")
REFERENCES "DB2INST1"."VS_PC" ("ID", "VERSIONID")
ON DELETE RESTRICT
ON UPDATE RESTRICT
NOT ENFORCED
ENABLE QUERY OPTIMIZATION;
Query:
======

INSERT INTO
DB2INST1.ASSPC
(
ID,
VERSIONID,
ASSVS_ID,
ASSVS_VERSIONID,
VS_PC_ID,
VS_PC_VERSIONID,
MULTIFAC
)
(
SELECT
DB2INST1.ASSPC.ID,
2,
DB2INST1.ASSVS.ID AS ASS_VS_ID,
DB2INST1.ASSVS.VERSIONID AS ASS_VS_VERSIONID,
DB2INST1.VS_PC.ID AS VS_PC_ID,
DB2INST1.VS_PC.VERSIONID AS VS_PC_VERSIONID,
DB2INST1.ASSPC.MULTIFAC
FROM
DB2INST1.ORG,
DB2INST1.ORG_VS,
DB2INST1.VS,
DB2INST1.DR,
DB2INST1.VS_PC,
DB2INST1.ACTIVITY,
DB2INST1.ASSPC,
DB2INST1.ASSVS
WHERE
DB2INST1.ORG_VS.ORG_ID = DB2INST1.ORG.ID
AND DB2INST1.ORG_VS.ORG_VERSIONID = DB2INST1.ORG.VERSIONID
AND DB2INST1.VS.DR_ID = DB2INST1.DR.ID
AND DB2INST1.VS.DR_VERSIONID = DB2INST1.DR.VERSIONID
AND DB2INST1.ORG_VS.VS_ID = DB2INST1.VS.ID
AND DB2INST1.ORG_VS.VS_VERSIONID = DB2INST1.VS.VERSIONID
AND DB2INST1.VS_PC.VS_ID = DB2INST1.VS.ID
AND DB2INST1.VS_PC.VS_VERSIONID = DB2INST1.VS.VERSIONID
AND DB2INST1.ASSPC.VS_PC_ID = DB2INST1.VS_PC.ID
AND DB2INST1.ASSPC.VS_PC_VERSIONID = DB2INST1.VS_PC.VERSIONID
AND DB2INST1.ASSVS.ORG_VS_ID = DB2INST1.ORG_VS.ID
AND DB2INST1.ASSVS.ORG_VS_VERSIONID = DB2INST1.ORG_VS.VERSIONID
AND DB2INST1.ASSPC.ASSVS_ID = DB2INST1.ASSVS.ID
AND DB2INST1.ASSPC.ASSVS_VERSIONID = DB2INST1.ASSVS.VERSIONID
AND DB2INST1.ORG.DELETE IS NULL
AND DB2INST1.ORG_VS.DELETE IS NULL
AND DB2INST1.VS.DELETE IS NULL
AND DB2INST1.DR.DELETE IS NULL
AND DB2INST1.VS_PC.DELETE IS NULL
AND DB2INST1.ACTIVITY.DELETE IS NULL
AND DB2INST1.ASSPC.DELETE IS NULL
AND DB2INST1.ASSVS.DELETE IS NULL

AND DB2INST1.ASSPC.VERSIONID = 1
AND DB2INST1.ORG.ID = 1
AND DB2INST1.ORG.VERSIONID = 1
)

Nov 12 '05 #1
1 2513
nomorems wrote:
I was trying to copy a range of records from a table to the same table
with a small modification. I was wondering why this takes a long time
compared to just doing a subselect from that table and insert to a new
table (without constraints). Could it be a problem with the constraints
checking capability or the index maintenance? The subselect itself
takes a small time, so that will not be the problem...

Before executing the query I tried to set the constraints checking off
by the following statements; but it doesn't work as I expected:

SET INTEGRITY FOR DB2INST1.ASSPC OFF
SET INTEGRITY FOR DB2INST1.ASSPCACT OFF
SET INTEGRITY FOR DB2INST1.ASSPCACTSIBLING OFF

Any suggestions are welcome...

Regards, Peter

TABLE:
======

CREATE TABLE "DB2INST1"."ASSPC" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY ( START WITH +1
INCREMENT BY +1 MINVALUE +1 MAXVALUE +2147483647 NO CYCLE NO CACHE
NO ORDER ),
"VERSIONID" INTEGER NOT NULL WITH DEFAULT 1,
"ASSVS_ID" INTEGER NOT NULL,
"ASSVS_VERSIONID" INTEGER NOT NULL,
"VS_PC_ID" INTEGER NOT NULL,
"VS_PC_VERSIONID" INTEGER NOT NULL,
"CREATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP,
"DELETE" TIMESTAMP,
"UPDATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP,
"MULTIFAC" DECIMAL(4,1)
) IN "USERSPACE1" ;
PRIMARY KEY:
============

ALTER TABLE "DB2INST1"."ASSPC"
ADD CONSTRAINT "CC1084276791058" PRIMARY KEY ("ID", "VERSIONID");

FOREIGN KEYS:
=============

ALTER TABLE "DB2INST1"."ASSPC"
ADD CONSTRAINT "CC1084276820350" FOREIGN KEY ("ASSVS_ID",
"ASSVS_VERSIONID")
REFERENCES "DB2INST1"."ASSVS" ("ID", "VERSIONID")
ON DELETE RESTRICT
ON UPDATE RESTRICT
NOT ENFORCED
ENABLE QUERY OPTIMIZATION;

ALTER TABLE "DB2INST1"."ASSPC"
ADD CONSTRAINT "CC1084276849722" FOREIGN KEY ("VS_PC_ID",
"VS_PC_VERSIONID")
REFERENCES "DB2INST1"."VS_PC" ("ID", "VERSIONID")
ON DELETE RESTRICT
ON UPDATE RESTRICT
NOT ENFORCED
ENABLE QUERY OPTIMIZATION;
Query:
======

INSERT INTO
DB2INST1.ASSPC
(
ID,
VERSIONID,
ASSVS_ID,
ASSVS_VERSIONID,
VS_PC_ID,
VS_PC_VERSIONID,
MULTIFAC
)
(
SELECT
DB2INST1.ASSPC.ID,
2,
DB2INST1.ASSVS.ID AS ASS_VS_ID,
DB2INST1.ASSVS.VERSIONID AS ASS_VS_VERSIONID,
DB2INST1.VS_PC.ID AS VS_PC_ID,
DB2INST1.VS_PC.VERSIONID AS VS_PC_VERSIONID,
DB2INST1.ASSPC.MULTIFAC
FROM
DB2INST1.ORG,
DB2INST1.ORG_VS,
DB2INST1.VS,
DB2INST1.DR,
DB2INST1.VS_PC,
DB2INST1.ACTIVITY,
DB2INST1.ASSPC,
DB2INST1.ASSVS
WHERE
DB2INST1.ORG_VS.ORG_ID = DB2INST1.ORG.ID
AND DB2INST1.ORG_VS.ORG_VERSIONID = DB2INST1.ORG.VERSIONID
AND DB2INST1.VS.DR_ID = DB2INST1.DR.ID
AND DB2INST1.VS.DR_VERSIONID = DB2INST1.DR.VERSIONID
AND DB2INST1.ORG_VS.VS_ID = DB2INST1.VS.ID
AND DB2INST1.ORG_VS.VS_VERSIONID = DB2INST1.VS.VERSIONID
AND DB2INST1.VS_PC.VS_ID = DB2INST1.VS.ID
AND DB2INST1.VS_PC.VS_VERSIONID = DB2INST1.VS.VERSIONID
AND DB2INST1.ASSPC.VS_PC_ID = DB2INST1.VS_PC.ID
AND DB2INST1.ASSPC.VS_PC_VERSIONID = DB2INST1.VS_PC.VERSIONID
AND DB2INST1.ASSVS.ORG_VS_ID = DB2INST1.ORG_VS.ID
AND DB2INST1.ASSVS.ORG_VS_VERSIONID = DB2INST1.ORG_VS.VERSIONID
AND DB2INST1.ASSPC.ASSVS_ID = DB2INST1.ASSVS.ID
AND DB2INST1.ASSPC.ASSVS_VERSIONID = DB2INST1.ASSVS.VERSIONID
AND DB2INST1.ORG.DELETE IS NULL
AND DB2INST1.ORG_VS.DELETE IS NULL
AND DB2INST1.VS.DELETE IS NULL
AND DB2INST1.DR.DELETE IS NULL
AND DB2INST1.VS_PC.DELETE IS NULL
AND DB2INST1.ACTIVITY.DELETE IS NULL
AND DB2INST1.ASSPC.DELETE IS NULL
AND DB2INST1.ASSVS.DELETE IS NULL

AND DB2INST1.ASSPC.VERSIONID = 1
AND DB2INST1.ORG.ID = 1
AND DB2INST1.ORG.VERSIONID = 1
)

SET INTEGRITY OFF pretty much takes the table out of the game. You will
not be able to operate DML (such as INSERT or SELECT) on the table.
Altering the constraints to NOT ENFORCED will do the trick.
After the INSERT you can then SET INTEGRITY OFF,
ALTER the constraints back to ENFORCED,
and then validate them in one shot by flipped SET INTEGRITY back on
either using the options of your choice.
If you don't use SET INTEGRITY OFF each ALTER TABLE statement willchech
the modified constraint right away, potentially resulting in more scans
=> longer time to finish.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: pb648174 | last post by:
Greeting, below is the complete SQL taken from aspfaq.com (retrieved from this newsgroup I believe) The query takes about two minutes to run. Does anybody have a better set based way (sub-second...
10
by: AC Slater | last post by:
I have 1 table (out of many) that has very poor performance when performing a select into on. The select statement is called multiple times. We've found each call to take almost 1 second... we...
1
by: Evan Smith | last post by:
My database is suffering from poor performance of late. Reports that used to run in a reasonable time, now take a while. The explain output show that the query is fully indexed, and the statistics...
3
by: sac | last post by:
I am using DB2 v8.1 on UNIX. At times the database shows extremely poor performance. I do not have dba/admin rights nor do I have the web based client for db2 v8.1. I have only command line...
4
by: Bill Thorne | last post by:
We have a COM object that has been wrappered for use in .NET and which can make calls which can take a while to execute. These are mainframe integration calls that might perform a lot of data...
20
by: John Mark Howell | last post by:
I had a customer call about some C# code they had put together that was handling some large arrays. The performance was rather poor. The C# code runs in about 22 seconds and the equivalent...
4
by: Jim Devenish | last post by:
I have converted an Access back-end to SQL Server back-end but am having some problems. The Access to Access application has been running well for some years. I have successfully copied all the...
1
by: Billy | last post by:
Hi All, I'm attempting to use the MapNetworkDrive <snippedbelow from entire code below with very poor performance results. Basically, I have very small 73kb text files that are rewritten daily...
4
by: joa2212 | last post by:
Hello everybody, I'm posting this message because I'm quiet frustrated. We just bought a software from a small software vendor. In the beginning he hosted our application on a small server at...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.