× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Yeah, already did Visual Explain and I have all the right indexes.

Just to let you all know, I really appreciate the help. Unfortunately
after I got it all working and doing awesome.... the spec changed and I
don't even need it. Oh well. I learned something new :D


Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777



Charles Wilt <charles.wilt@xxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
02/11/2011 08:43 AM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>


To
"RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx>
cc

Subject
Re: More efficient way to write this SQL Statement???






Bryce,

Make sure you at least have indexes on est(tcust, tship, stadtp) and
rcm(ccust)...

Select Cast(tcust As Numeric(6,0)), tship, stadtp, tname,
tadr1,tadr2, tadr3, tste, tpost, tphone
From est join rcm on tcust = ccust
where
(tadr3 = '' or tadr3 = :cszESTCity)
and (tste = '' or tste = :cszESTState)
and (tpost = '' or tpost = :cszESTZip)
and (tid = 'ST')
and (cad3 = '' or cad3 <> :cszESTCity)
and (cste = '' or cste <> :cszESTState)
and (czip = '' or czip <> :cszESTZip)
and (cmid = 'CM')
Order By tcust, tship, stadtp;

Do a visual explain on the above and see if any additional indexes are
recommended.

Also read this:
https://www-304.ibm.com/partnerworld/wps/servlet/ContentHandler/servers/enable/site/bi/strategy/index.html




HTH,
Charles


On Thu, Feb 10, 2011 at 4:59 PM, Bryce Martin <BMartin@xxxxxxxxxxxx>
wrote:
I have a static sql statement I'm using in an SQLRPGLE program. It
takes
about 20 seconds to execute and I need to make it faster if at all
possible...any suggestions will be greatly appreciated...

Here is the statement...

Exec SQL
Declare CSZEST1 Cursor For
Select Cast(tcust As Numeric(6,0)), tship, stadtp, tname,
tadr1,
tadr2, tadr3, tste, tpost, tphone
From est
Where tcust not in(Select ccust
From rcm
Where cad3 = (case when :cszESTCity <> ''
then :cszESTCity else
cad3 End)
and cste = (case when :cszESTState<>''
then :cszESTState else
cste End)
and czip = (case when :cszESTZip <> ''
then :cszESTZip else
czip
End)
and cmid = 'CM')
and tadr3 = (case when :cszESTCity <> ''
then :cszESTCity else tadr3 End)
and tste = (case when :cszESTState <> ''
then :cszESTState else tste End)
and tpost = (case when :cszESTZip <> ''
then :cszESTZip else tpost End)
and tid = 'ST'
Order By tcust, tship, stadtp;

The data is structured as follows. There are 2 files, RCM and EST. RCM
is the customer master and EST is the address master for customers. So
the key from RCM to EST is CCUST = TCUST.

TSHIP and STADTP together with TCUST form a unique record. What happens
is the user can specify a City, State, and/or Zip. If they are not
blank
I need to use them as inclusion criteria. What I want are any records
in
EST that meet the City/State/Zip criteria where the master RCM record
does
not.

I hope this is enough clear info.
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
--- This message (including any attachments) is intended only for the
use of the individual or entity to which it is addressed and may contain
information that is non-public, proprietary, privileged, confidential, and
exempt from disclosure under applicable law. If you are not the intended
recipient, you are hereby notified that any use, dissemination,
distribution, or copying of this communication is strictly prohibited. If
you have received this communication in error, please notify us and
destroy this message immediately. ---
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.