Huge tables, multiple commands, deathly slow query via Crystal

Hi, this is both an Oracle 9i and Crystal XI R2 question.

I have three large tables, and I'm trying to crunch them to create a report - however the resulting dataset is so slow to appear the report is useless.  It's ran for over a day before..... below is my Query.  Any suggestions on how to speed this up - even to 2 hours would be great :-)

Three Crystal Commands:
QRY_DESTINATION_WHS:
SELECT COMPANY_CODE, DOCUMENT_NUMBER, MOVEMENT_DATE, WAREHOUSE, PART_CODE, IC_LOT_NUMBER, USERNAME,IC_MOVE_QUANTITY, IC_STATUS_CODE ,  DOCUMENT_LINE, DOCUMENT_SEQUENCE, UNIT_OF_MEASURE
FROM fin_prod.IC_MOVEMENTS
WHERE MOVEMENT_CODE = 'WHTO' and SOURCE_MODULE = 'IC' AND IC_STATUS_CODE <> 'CONFINQ'

QRY_SORUCE_WHS:
SELECT COMPANY_CODE, DOCUMENT_NUMBER, MOVEMENT_DATE, WAREHOUSE, PART_CODE, IC_LOT_NUMBER, USERNAME,IC_MOVE_QUANTITY, IC_STATUS_CODE,
 DOCUMENT_LINE, DOCUMENT_SEQUENCE, UNIT_OF_MEASURE
FROM fin_prod.IC_MOVEMENTS
WHERE MOVEMENT_CODE = 'WHFR' AND SOURCE_MODULE = 'IC' AND IC_STATUS_CODE <> 'CONFIN'
QRY_LPN:
SELECT COMPANY_CODE, DC_LICENSE_PLATE_ID,WAREHOUSE, BIN_LOCATION, WH_XFER_DOC_REFERENCE, DC_LICENSE_PLATE_LINE,
              PART_CODE, DOC_REFERENCE, CAST(DOC_LINE AS VARCHAR(8)) AS DOC_LINE_NUMBER
FROM  FIN_PROD.DC_LICENSE_PLATE_HISTORY
WHERE DC_LICENSE_PLATE_STATUS='ACTIVE'
GROUP BY COMPANY_CODE, DC_LICENSE_PLATE_ID, WAREHOUSE, BIN_LOCATION, WH_XFER_DOC_REFERENCE, DC_LICENSE_PLATE_LINE,
               PART_CODE, DOC_REFERENCE, CAST(DOC_LINE AS VARCHAR(8))
------------------
the query:
oracle1
SELECT COMPANY_CODE, DOCUMENT_NUMBER, MOVEMENT_DATE, WAREHOUSE, PART_CODE, IC_LOT_NUMBER, USERNAME,IC_MOVE_QUANTITY, IC_STATUS_CODE,
 DOCUMENT_LINE, DOCUMENT_SEQUENCE, UNIT_OF_MEASURE
FROM fin_prod.IC_MOVEMENTS
WHERE MOVEMENT_CODE = 'WHFR' AND SOURCE_MODULE = 'IC' AND IC_STATUS_CODE <> 'CONFIN'
 EXTERNAL JOIN QRY_SORUCE_WHS.COMPANY_CODE={?oracle1: QRY_DESTINATION_WHS.COMPANY_CODE} AND QRY_SORUCE_WHS.DOCUMENT_NUMBER={?oracle1: QRY_DESTINATION_WHS.DOCUMENT_NUMBER} AND QRY_SORUCE_WHS.PART_CODE={?oracle1: QRY_DESTINATION_WHS.PART_CODE} AND QRY_SORUCE_WHS.DOCUMENT_LINE={?oracle1: QRY_DESTINATION_WHS.DOCUMENT_LINE} AND QRY_SORUCE_WHS.DOCUMENT_SEQUENCE={?oracle1: QRY_DESTINATION_WHS.DOCUMENT_SEQUENCE} AND QRY_SORUCE_WHS.UNIT_OF_MEASURE={?oracle1: QRY_DESTINATION_WHS.UNIT_OF_MEASURE}


oracle1
SELECT COMPANY_CODE, DOCUMENT_NUMBER, MOVEMENT_DATE, WAREHOUSE, PART_CODE, IC_LOT_NUMBER, USERNAME,IC_MOVE_QUANTITY, IC_STATUS_CODE ,  DOCUMENT_LINE, DOCUMENT_SEQUENCE, UNIT_OF_MEASURE
FROM fin_prod.IC_MOVEMENTS
WHERE MOVEMENT_CODE = 'WHTO' and SOURCE_MODULE = 'IC' AND IC_STATUS_CODE <> 'CONFINQ'
 EXTERNAL JOIN QRY_DESTINATION_WHS.COMPANY_CODE={?oracle1: QRY_SORUCE_WHS.COMPANY_CODE} AND QRY_DESTINATION_WHS.DOCUMENT_NUMBER={?oracle1: QRY_SORUCE_WHS.DOCUMENT_NUMBER} AND QRY_DESTINATION_WHS.PART_CODE={?oracle1: QRY_SORUCE_WHS.PART_CODE} AND QRY_DESTINATION_WHS.DOCUMENT_LINE={?oracle1: QRY_SORUCE_WHS.DOCUMENT_LINE} AND QRY_DESTINATION_WHS.DOCUMENT_SEQUENCE={?oracle1: QRY_SORUCE_WHS.DOCUMENT_SEQUENCE} AND QRY_DESTINATION_WHS.UNIT_OF_MEASURE={?oracle1: QRY_SORUCE_WHS.UNIT_OF_MEASURE} AND QRY_DESTINATION_WHS.COMPANY_CODE={?oracle1: QRY_LPN.COMPANY_CODE} AND QRY_DESTINATION_WHS.DOCUMENT_NUMBER={?oracle1: QRY_LPN.DOC_REFERENCE} AND QRY_DESTINATION_WHS.DOCUMENT_LINE={?oracle1: QRY_LPN.DOC_LINE_NUMBER}


oracle1
SELECT COMPANY_CODE, DC_LICENSE_PLATE_ID,WAREHOUSE, BIN_LOCATION, WH_XFER_DOC_REFERENCE, DC_LICENSE_PLATE_LINE,
              PART_CODE, DOC_REFERENCE, CAST(DOC_LINE AS VARCHAR(8)) AS DOC_LINE_NUMBER
FROM  FIN_PROD.DC_LICENSE_PLATE_HISTORY
WHERE DC_LICENSE_PLATE_STATUS='ACTIVE'
GROUP BY COMPANY_CODE, DC_LICENSE_PLATE_ID, WAREHOUSE, BIN_LOCATION, WH_XFER_DOC_REFERENCE, DC_LICENSE_PLATE_LINE,
               PART_CODE, DOC_REFERENCE, CAST(DOC_LINE AS VARCHAR(8))
 EXTERNAL JOIN QRY_LPN.COMPANY_CODE={?oracle1: QRY_DESTINATION_WHS.COMPANY_CODE} AND QRY_LPN.DOC_REFERENCE={?oracle1: QRY_DESTINATION_WHS.DOCUMENT_NUMBER} AND QRY_LPN.DOC_LINE_NUMBER={?oracle1: QRY_DESTINATION_WHS.DOCUMENT_LINE}
Dan FloodDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
The very first thing you can do to speed up the report is to consolidate all commands into either a single Command or a Stored Procedure, which is conceptually the same as a SQL Command Object (it's just stored on the DB, not in Crystal).  Commands and Procedures are executed fully before any of the joins or additional filters in Crystal Reports are applied.  This means that you're executing three commands, bringing back all possible records from the database across the network to the client before you even apply the joins....  That's bad.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Naveen KumarProduction Manager / Application Support ManagerCommented:
from the database side, it is good to have an index for those columns used in the where clause as long
as we are not using <>, not in , not like, is null because index won't be used even if index is there.

WHERE MOVEMENT_CODE = 'WHTO' and SOURCE_MODULE = 'IC' AND IC_STATUS_CODE <> 'CONFINQ'

so any other way to modify the <> in the where clause will speed up the query.

Thanks
0
MohanKNairCommented:
The best practice to tune SQL in reports is by making use of SQLTRACE and TKPROF reports. Enable SQLTRACE for the crystal reports sessionand run the reports. This will generate a trace file in the server. Gererate TKPROF report with EXPLAIN PLAN. This report will show all the SQL's used by the report and the execution plan used and cost of each query.

If any query is executed many times then the network traffic may be high. Try to buffer some data in the front-end.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
I don't disagree with the comments from either nav_kum_v or MohanKNair, but neither of those suggestions pertain to actual Crystal Reports functionality and neither will solve your immediate problem.  Both are, however, good suggestions to consider after you've removed the multiple commands.

~Kurt
0
Dan FloodDeveloperAuthor Commented:
Thanks I have tried to reduce it to one command, but it's been running for several hours now.  I am not sure how to enable sqltrace for this....  I'm a MSSQL guy just getting my feet wet with Oracle :)
0
Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
1)  Can you please post the current Command?

2)  Do you have any subreport, shared variables, additional parameters or selection criteria outside of the command?

3)  If you run the command in Toad, SQL+ or some other analyser tool, how long does the query take?

~Kurt
0
MohanKNairCommented:
The first SQL statement in crystal reports shoud be to enable the SQLTRACE and the last SQL is for disabling the sqltrace

Start of reports

ALTER SESSION SET SQL_TRACE=TRUE;

end of the reports

ALTER SESSION SET SQL_TRACE=FALSE;;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.