473,569 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Performance issue: Need to force Optimizer use a specific Index


Hi Expert DBAs,
I am facing an issue with a query, can anyone help me through?
I have a Query:
UPDATE VMUS.MSG_MSTR a SET MSG_STA_ID =5
WHERE a.PROC_ID =2 AND
a.file_type_id =1 AND
MSG_STA_ID IN (1, 3) AND
DATA_REQ_DT IS NOT NULL
We have 2 indexes for the table:
Indname Column names
XEM0602 +MSG_STA_ID+FIL E_TYPE_ID+PROC_ ID
XEM0605 +PROC_ID+FILE_T YPE_ID+SOURCE_F ILE_NM_TX

Query is using XEM0605 index, but I would like query to use index
XEM0602 which would be more economical. Please suggest a way to
achieve this.
I tried tweaking the sysstat tables no success. Also tried putting
query as
UPDATE VMUS.MSG_MSTR a SET MSG_STA_ID =5
WHERE a.MSG_STA_ID IN (1, 3) AND
a.PROC_ID =2 AND
a.file_type_id =1 AND
DATA_REQ_DT IS NOT NULL
No success.

If instead of the clause , " MSG_STA_ID IN (1, 3) " , I change to
MSG_STA_ID = 1 in UPDATE query optimizer uses my required index
"XEM0602". But for the IN clause it just disregards the field.Please
help.
An early response is well appreciated as issue is holding jobs.

Thanks for your time. ....
Regards
V
------------------------------------------------------------------------
IT Interview Questions : http://www.geekinterview.com IT Tutorials and Articles : http://www.geekarticles.com Oracle and Oracle Apps Training : http://www.exforsys.com
Dec 9 '05 #1
5 9830
Venkatesh Subbaramu wrote:
Hi Expert DBAs,
I am facing an issue with a query, can anyone help me through?
I have a Query:
UPDATE VMUS.MSG_MSTR a SET MSG_STA_ID =5
WHERE a.PROC_ID =2 AND
a.file_type_id =1 AND
MSG_STA_ID IN (1, 3) AND
DATA_REQ_DT IS NOT NULL
We have 2 indexes for the table:
Indname Column names
XEM0602 +MSG_STA_ID+FIL E_TYPE_ID+PROC_ ID
XEM0605 +PROC_ID+FILE_T YPE_ID+SOURCE_F ILE_NM_TX

Query is using XEM0605 index, but I would like query to use index
XEM0602 which would be more economical. Please suggest a way to
achieve this.

Hmm, I certainly understand why the optimizer can't resist an index
where it has the two leading key colmuns nailed.

Try this... just a hunch...
UPDATE VMUS.MSG_MSTR a SET MSG_STA_ID =5
WHERE (a.PROC_ID, a.file_type_id, a.MSG_STA_ID)
IN (SELECT * FROM (VALUES(2, 1, 1), (2, 1, 3)) AS X)
AND DATA_REQ_DT IS NOT NULL

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Dec 9 '05 #2
If you reorg the table based on the index you specified (or make it the
clustering index), and then run runstats with distirubuiton on key
columns, then DB2 will choose the most efficient access path 99.9% of
the time.

Dec 9 '05 #3
Try this

Make the table VOLATILE.

cheers....
Shashi Mannepalli

m0****@yahoo.co m wrote:
If you reorg the table based on the index you specified (or make it the
clustering index), and then run runstats with distirubuiton on key
columns, then DB2 will choose the most efficient access path 99.9% of
the time.


Dec 9 '05 #4
Making a table volatile will encourage index usage, but I am not sure
it will encourage one index over another.

Dec 9 '05 #5
m0****@yahoo.co m wrote:
If you reorg the table based on the index you specified (or make it the
clustering index), and then run runstats with distirubuiton on key
columns, then DB2 will choose the most efficient access path 99.9% of
the time.


And if you run into the other 0.1%, you might want to contact IBM support to
get the problem fixed. I believe the philosophy for DB2 is that the
optimizer is supposed to do the right thing and not that the application
developer has to do the optimizer's job by giving hints.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 12 '05 #6

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

Similar topics

3
5211
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and includes the following columns: DocID (INTEGER, PRIMARY KEY, CLUSTERED) IsRecord (INTEGER, NONCLUSTERED)
5
4478
by: Bernie | last post by:
Greetings, I have 3 servers all running SQL Server 2000 - 8.00.818. Lets call them parent, child1, and child 2. On parent, I create a view called item as follows: CREATE view Item as select * from child1.dbchild1.dbo.Item union all select * from child2.DBChild2.dbo.Item
12
8326
by: serge | last post by:
I have an SP that is big, huge, 700-800 lines. I am not an expert but I need to figure out every possible way that I can improve the performance speed of this SP. In the next couple of weeks I will work on preparing SQL statements that will create the tables, insert sample record and run the SP. I would hope people will look at my SP and...
6
13128
by: pragile | last post by:
I have a stored procedure that has some problems with slow performance. The procedure has 2 parameters @firstname varchar(100) @lastname varchar(100) These parameters can have values like a%, that is wildcard searches. The strange thing is that if one of the parameters has the value %, and the other one a%, the performance is very bad....
6
2311
by: teedilo | last post by:
We have an application with a SQL Server 2000 back end that is fairly database intensive -- lots of fairly frequent queries, inserts, updates -- the gamut. The application does not make use of performance hogs like cursors, but I know there are lots of ways the application could be made more efficient database-wise. The server code is...
14
5393
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why...
4
1769
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is good form to have a single query with base table with criteria joined to a related table - all in one query? Or should I do a two-step, first query...
8
3062
by: Michel Esber | last post by:
Hello, DB2 V8 FP 11 running on Linux. Given two tables: T_SW_ID (SW_ID INTEGER, SW_NAME VARCHAR); T_SW (MACHINE_ID varchar, SW_ID DECIMAL (8), VERSION varchar, Product_ID varchar)
24
2629
by: 73blazer | last post by:
So a friend an I inadvertanly came across this problem while diagnosing another: I have a table: create table test.test (g_id int not null, g_width int, g_height int); create index testtest on test.test (g_id); I have about 5000 rows in this table A query run through CLI C program using the prep/exec method containing
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.