473,498 Members | 1,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

very different costs for select and update - why?

simple query

select * from "Result" res where (res."QID" = 51541 or res."QID" =
51542)

works fine ("SRV-BL"."Result" ~ 900000 rows) and returns 36 rows

but update - no!

update "SRV-BL"."Result" res set "Status"=0 where (res."QID" = 51541
or res."QID" = 51542)

Exec Time: 2.394387 seconds
Number of Agents created: 1
User CPU: 2.343750 seconds
System CPU: 0.031250 seconds
Fetch Count: 0
Sorts: 0
Total sort time: 0
Sort overflows: 0
Rows read: 2684799
Rows written: 38
Internal rows deleted: 0
Internal rows updated: 0
Internal rows inserted: 0
Bufferpool data logical reads: 25671
Bufferpool data physical reads: 1
Bufferpool temporary data logical reads: 894970

Explains show me - update has tablescan.

Access Plan:
-----------
Total Cost: 100916
Query Degree: 0

Rows
RETURN
( 1)
Cost
I/O
|
4242.54
UPDATE
( 2)
100916
29357.5
/---+---\
4242.54 875673
NLJOIN TABLE: SRV-BL
( 3) Result
46388.8
25115
/----+---\
875673 0.00484489
TBSCAN TBSCAN
( 4) ( 5)
44701.6 0.012825
25115 0
| |
875673 2
TABLE: SRV-BL TEMP
Result ( 6)
0.0037412
0
|
2
TBSCAN
( 7)
3.66067e-005
0
|
2
TABFNC: SYSIBM
GENROW
But for select

Access Plan:
-----------
Total Cost: 1366.05
Query Degree: 0

Rows
RETURN
( 1)
Cost
I/O
|
4242.54
NLJOIN
( 2)
1366.05
608.865
/------+------\
2 2121.27
TBSCAN FETCH
( 3) ( 4)
3.66067e-005 683.037
0 304.432
| /---+---\
2 2121.27 875673
TABFNC: SYSIBM IXSCAN TABLE: SRV-BL
GENROW ( 5) Result
58.0589
4.44714
|
875673
INDEX: RUAPNA
RESULT_QID_SHORT


CREATE TABLE SRV-BL.Result
(BLID INTEGER,
QID INTEGER,
PatternID INTEGER,
TimeStamp TIMESTAMP,
SecurityGroupName SRV-BL.VA,
GroupName SRV-BL.VA,
PatternName SRV-BL.VA,
Matched INTEGER,
BLAddressID INTEGER,
QAddressID INTEGER,
BLPhoneID INTEGER,
QPhoneID INTEGER,
BLDocID INTEGER,
QDocID INTEGER,
MatchDate TIMESTAMP
);

CREATE INDEX RUAPNA.RESULT_QID_SHORT
ON SRV-BL.Result
(QID ASC
);

Andy

Aug 29 '06 #1
1 2238
Hmmm...I've seen something like this on an UPDATE to a base table of an
MQT. Just for kicks, change your OR to an IN, i.e.,

update "SRV-BL"."Result" res set "Status"=0 where res."QID" IN (51541,
51542);

I did this, and it made a HUGE difference in my situation. It's all
about when and how the optimizer chooses to use that little TEMP table
it seems to like to create in certain circumstances :-).

Otherwise, you might want to try using MERGE to do the UPDATE--I've had
amazing luck with Serge's advice to convert some DELETEs to MERGEs; you
may have similar luck with an UPDATE.

Regards,

--Jeff

bughunter@ru wrote:
simple query

select * from "Result" res where (res."QID" = 51541 or res."QID" =
51542)

works fine ("SRV-BL"."Result" ~ 900000 rows) and returns 36 rows

but update - no!

update "SRV-BL"."Result" res set "Status"=0 where (res."QID" = 51541
or res."QID" = 51542)

Exec Time: 2.394387 seconds
Number of Agents created: 1
User CPU: 2.343750 seconds
System CPU: 0.031250 seconds
Fetch Count: 0
Sorts: 0
Total sort time: 0
Sort overflows: 0
Rows read: 2684799
Rows written: 38
Internal rows deleted: 0
Internal rows updated: 0
Internal rows inserted: 0
Bufferpool data logical reads: 25671
Bufferpool data physical reads: 1
Bufferpool temporary data logical reads: 894970

Explains show me - update has tablescan.

Access Plan:
-----------
Total Cost: 100916
Query Degree: 0

Rows
RETURN
( 1)
Cost
I/O
|
4242.54
UPDATE
( 2)
100916
29357.5
/---+---\
4242.54 875673
NLJOIN TABLE: SRV-BL
( 3) Result
46388.8
25115
/----+---\
875673 0.00484489
TBSCAN TBSCAN
( 4) ( 5)
44701.6 0.012825
25115 0
| |
875673 2
TABLE: SRV-BL TEMP
Result ( 6)
0.0037412
0
|
2
TBSCAN
( 7)
3.66067e-005
0
|
2
TABFNC: SYSIBM
GENROW
But for select

Access Plan:
-----------
Total Cost: 1366.05
Query Degree: 0

Rows
RETURN
( 1)
Cost
I/O
|
4242.54
NLJOIN
( 2)
1366.05
608.865
/------+------\
2 2121.27
TBSCAN FETCH
( 3) ( 4)
3.66067e-005 683.037
0 304.432
| /---+---\
2 2121.27 875673
TABFNC: SYSIBM IXSCAN TABLE: SRV-BL
GENROW ( 5) Result
58.0589
4.44714
|
875673
INDEX: RUAPNA
RESULT_QID_SHORT


CREATE TABLE SRV-BL.Result
(BLID INTEGER,
QID INTEGER,
PatternID INTEGER,
TimeStamp TIMESTAMP,
SecurityGroupName SRV-BL.VA,
GroupName SRV-BL.VA,
PatternName SRV-BL.VA,
Matched INTEGER,
BLAddressID INTEGER,
QAddressID INTEGER,
BLPhoneID INTEGER,
QPhoneID INTEGER,
BLDocID INTEGER,
QDocID INTEGER,
MatchDate TIMESTAMP
);

CREATE INDEX RUAPNA.RESULT_QID_SHORT
ON SRV-BL.Result
(QID ASC
);

Andy
Aug 29 '06 #2

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

Similar topics

4
2815
by: Google Mike | last post by:
I have RH9 and am using the PHP and MySQL that came with it. I was doing fine with all manner of my web pages for this app until I started having this very strange problem. It's a work order...
2
1634
by: Jim Moseby | last post by:
I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman...
2
555
by: Robert | last post by:
Hi there! I have a problem I can't get rid of... I hope anyone can help me with it! For a room-booking application I need to select available rooms for a given period. First I do the...
16
21254
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest week (when the db grow a lot). The DB is around...
6
1690
by: Pedro Alves | last post by:
Hi I'm having serious problems with a mission critical app that runs on postgres (and has been running for the past 3 years). It's rather large, and lately things are not going well. The...
6
2631
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about...
21
1646
by: Steve | last post by:
Hi, I have a form containing a lot of various forms objects (about 120-150). It takes about 10 minutes for the solution to load (only one project). If I modify the corresponding .h file and...
6
3280
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
2
7128
by: ibcarolek | last post by:
We have a field which is decimal (9,2) and another which is decimal (9,3). Is there anyway to subtract the two and get a precision 3 value without changing the first field to 9,3? For instance,...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7167
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5464
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.