Hi Vern,

Thanks for the explanation. There are no logicals or indexes with the
keys needed for the joins for I am in the process of creating the suggested
indexes. Do you see a problem with that? These are over files with over a
million records each. The client wants to get the run time down to under 2
minutes. It is currently at 5 minutes.

All the best,

Richard Reeve


On Wed, Oct 13, 2021 at 8:18 AM Vern Hamberg <vhamberg@xxxxxxxxxxxxxxx>
wrote:

Hi Richard

Famous IBM watchword - it depends.

In general, you want indexes (logical files with keys) that align your
WHERE clause and that support your JOINs - you have a bunch, man!!

First, do you have an LF on DBWHWHS over ship date and status? That'd be
my first choice, to limit the records in the main table in your JOINs.

In the JOINs, an example - have an index on the files that are joined to
DBWHWHS - so do you have a logical on DBWHWHL over doc number? Stuff
like that.

Indexes might not be used directly, but they can help the optimizer
choose the best plan. But you need to be careful about just willy-nilly
creating them. Every index means there will be more time taken for
updating them when records change or are added or deleted from the table
(physical file). So performance overall is a thing to look at.

I'd see what you already have - in Visual Explain, it should tell you
that it chose certain indexes and maybe why - that'll help.

Here is a link to an article on SQL performance that might help -

https://www.ibm.com/support/pages/sites/default/files/inline-files/$FILE/indexing
and statistics 2011.pdf
<
https://www.ibm.com/support/pages/sites/default/files/inline-files/$FILE/indexing%20and%20statistics%202011.pdf>

- by Michael Cain and Kent Milligan, true experts on this topic.

Enjoy!
Vern

On 10/13/2021 7:43 AM, Richard Reeve wrote:
This is my first shot at visual explain. It shows the creation of 4
temporary indexes. Does that indicate that I should create those 4
indexes?
All the best,

Richard Reeve


On Wed, Oct 13, 2021 at 7:38 AM Jim Oberholtzer <
midrangel@xxxxxxxxxxxxxxxxx>
wrote:

What has the optimizer suggested? Have you put this into visual
explain
to see how the optimizer is actually running the statement?

Jim Oberholtzer
Agile Technology Architects



On Oct 13, 2021, at 7:11 AM, Richard Reeve <rjrjr64@xxxxxxxxx> wrote:

All,

I have this SQL statement that runs quite slow. Any idea how I
might
speed this up?

SELECT

WHS.DBWHS_SHIPMENT_NBR
,WHS.DBWHS_DOC_NBR
,COR.DBCOR_ORDER_NBR
,COR.DBCOR_ORDER_TYPE
,WHL.DBWHL_DESCRIPTION
---,' ' AS sggroup
---,' ' AS sold_to-pt
,COR.DBCOR_CUST_PO_NBR
---, ' ' as fol-doc
,WHS.DBWHS_BOL_NBR
,WHS.DBWHS_WEIGHT
,WHS.DBWHS_CARTONS
,WHS.DBWHS_SHIP_DATE
,WHS.DBWHS_TRANS_ID
---,' ' as proc-id
,WHS.DBWHS_METHOD
,SHP.DBSHP_CUSTOMER
,SHP.DBSHP_NAME
,SHP.DBSHP_NAME
,SHP.DBSHP_ADDR1
,SHP.DBSHP_ADDR2
,SHP.DBSHP_CITY
,SHP.DBSHP_STATE
,SHP.DBSHP_ZIP
---,DBBLSHP.''COST CENTER
,SPC.DBSPC_COMMENT
---,'' as whn
,WDH.DBWDH_DESTINATION
,WDH.DBWDH_DEST_NAME
,SHP.DBSHP_TAX_CODE ---,' ' as tax_juris
,WDH.DBWDH_DEST_STATE
,WDH.DBWDH_DEST_CNTRY
,WDH.DBWDH_DEST_ZIP
,WHS.DBWHS_CARRIER
,VEN.DBVEN_VENDOR_VNAME---,'v' as carrier name
,WHS.DBWHS_FREIGHT_CODE---', as incoterm code
---,' ' as incoterm description
,WHS.DBWHS_FRT_CHG_CURR
,ARH.DBARH_TRAN_AMT
---,' ' as acct
,ACM.DBACM_CREDIT_LIM
---,' ' as pint
,WHS.DBWHS_COMPANY
,COR.DBCOR_ORDER_DATE
---,WDM.DBWDM_UPDATE_DATE
,WHS.DBWHS_STATUS
,WHS.DBWHS_SHIP_DATE
---,'LAW' as ERP-IDENTIFIER

FROM LAWDBF7B.DBWHWHS WHS

LEFT JOIN LAWDBF7B.DBWHWHL WHL ON WHS.DBWHS_DOC_NBR=WHL.DBWHL_DOC_NBR
LEFT JOIN LAWDBF7B.DBWHWDH WDH ON WHS.DBWHS_DOC_NBR=WDH.DBWDH_DOC_NBR
LEFT JOIN LAWDBF7B.DBBLSHP SHP ON
WHS.DBWHS_CUST_SHIP_TO=SHP.DBSHP_SHIP_TO
LEFT JOIN LAWDBF7B.DBAPVEN VEN ON WHS.DBWHS_VENDOR=VEN.DBVEN_VENDOR
LEFT JOIN LAWDBF7B.DBBLSPC SPC ON SHP.DBSHP_CUSTOMER=SPC.DBSPC_CUSTOMER
LEFT JOIN LAWDBF7B.DBARARH ARH ON ARH.DBARH_CUSTOMER=SHP.DBSHP_CUSTOMER
LEFT JOIN LAWDBF7B.DBARACM ACM ON ACM.DBACM_CUSTOMER=SHP.DBSHP_CUSTOMER
LEFT JOIN LAWDBF7B.DBBLCOR COR ON COR.DBCOR_CUSTOMER=SHP.DBSHP_CUSTOMER

WHERE WHS.DBWHS_SHIP_DATE>='20210930' AND WHS.DBWHS_STATUS='3'


All the best,

Richard Reeve
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


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-2022 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.