473,396 Members | 2,013 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,396 software developers and data experts.

DB2 SQL Statement Optimization

I am trying to pull some data from a JDEdwards system, I am having a
lot of trouble with the sql statement that follows. It takes much
longer than I would expect it to (several hours for 1500 records. Is
there a way to optimize this statement?

Thanks very much,
JH

SELECT
TRIM("IBSTKT") AS
"STOCK_CODE",
TRIM("IBMCU") || '{$U_SEPARATOR_CHAR}' ||
TRIM(CAST("IBITM" AS CHAR(8))) AS "ID"
FROM {$U_JDDATALIB}."F4102", {$U_JDDATALIB}."F4111"
WHERE
IBMCU = ILMCU
AND IBITM = ILITM
AND
(TRIM("ILMCU") = '2784' OR TRIM("ILMCU") = '2744' AND ILAN8 = 2784)
AND
(ILTRQT <> 0 AND ILPAID <> 0)
AND
(F4111."ILCRDJ" >= 103200 AND F4111."ILCRDJ" < 103300)
Nov 12 '05 #1
1 9801
"JHam" <je*************@ufa.com> wrote in message
news:ce**************************@posting.google.c om...
I am trying to pull some data from a JDEdwards system, I am having a
lot of trouble with the sql statement that follows. It takes much
longer than I would expect it to (several hours for 1500 records. Is
there a way to optimize this statement?

Thanks very much,
JH

SELECT
TRIM("IBSTKT") AS
"STOCK_CODE",
TRIM("IBMCU") || '{$U_SEPARATOR_CHAR}' ||
TRIM(CAST("IBITM" AS CHAR(8))) AS "ID"
FROM {$U_JDDATALIB}."F4102", {$U_JDDATALIB}."F4111"
WHERE
IBMCU = ILMCU
AND IBITM = ILITM
AND
(TRIM("ILMCU") = '2784' OR TRIM("ILMCU") = '2744' AND ILAN8 = 2784)
AND
(ILTRQT <> 0 AND ILPAID <> 0)
AND
(F4111."ILCRDJ" >= 103200 AND F4111."ILCRDJ" < 103300)


You didn't say which DB2 version and OS. I would try it without the TRIM
function on the WHERE clause. Not sure why you are using it.

(ILMCU = '2784' OR ILMCU = '2744' AND ILAN8 = 2784)

Get rid of single quotes if ILMCU is numeric.

You also "should" to use another parenthesis in the above so it is
absolutely clear.

You will also need some indexes, probably at least on ILMCU and ILAN8. Other
indexes may help, but it cannot be determined without more information on
cardinality of the columns.
Nov 12 '05 #2

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

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
26
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the...
5
by: Fred | last post by:
Hi all, I have done a lot of experimentations using several "or" predicates within an sql select statements on mysql. My only conclusion so far is that whatever syntax or order I use it is...
37
by: Thomas Matthews | last post by:
Hi, My son is writing a program to move a character. He is using the numbers on the keypad to indicate the direction of movement: 7 8 9 4 5 6 1 2 3 Each number has a direction except...
13
by: jimjim | last post by:
Hello all, I ve come across the following code fragment and I was wondering why is the copy ctr called on return (rather than just returning the string statement obj. TIA string...
2
by: Dave Markle | last post by:
Good afternoon. I was just going through my code, analyzing it with FXCop, and FxCop gave me the following error on this code: MY CODE: Select Case termYears Case 5 : retVal.Append("1") Case...
67
by: Rui Maciel | last post by:
I've been delving into finite state machines and at this time it seems that the best way to implement them is through an intense use of the goto statement. Yet, everyone plus their granmother is...
22
by: John | last post by:
Hi Folks, I'm experimenting a little with creating a custom CEdit control so that I can decide on what the user is allowed to type into the control. I started off only allowing floating point...
26
by: a.mil | last post by:
I am programming for code-speed, not for ansi or other nice-guy stuff and I encountered the following problem: When I have a for loop like this: b=b0; for (a=0,i=0;i<100;i++,b--) { if (b%i)...
0
ADezii
by: ADezii | last post by:
One frequently asked question at TheScripts is "Should I use a Stored Query or an SQL Statement in those situations that require a Query (RecordSets, RecordSources, Append, Delete, Update Operations,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.