if you can put some test data of the TABLE, and the output format and criteria it will be easier for us to give some suggestions.
Main Topics
Browse All TopicsHi there - hope someone is able to help.
Previously someone was kind enough to write me a query. Oracle 10 db.
( background - http://www.experts-exchang
Basically the query ( see below ) is taking far too long to run and I was looking for suggestions to improve the performance of this.
i.e. is there a more efficient way to achieve the same results.
note - this needs to be a query, I'm not able to create temporary tables etc to achieve this.
Neither am I able to create indexes etc. to help with this.
SQL ;
SELECT * FROM
(SELECT
MIN(DECODE(ACC_CODE,91,SAL
DECODE(ACC_CODE,92,DELIVER
FROM TABLE)
WHERE DELIVERY_DATE IS NOT NULL
Any suggestions ?
Thank you,
d.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
Explain plan ( via TOAD )
SELECT STATEMENT Optimizer=ALL_ROWS (Cost=76979 Card=11171690 Bytes=346322390)
SORT (GROUP BY) (Cost=76979 Card=11171690 Bytes=346322390)
VIEW (Cost=60061 Card=11171690 Bytes=346322390)
WINDOW (SORT) (Cost=60061 Card=11171690 Bytes=368665770)
PARTITION RANGE (ALL)
TABLE ACCESS (FULL) OF MASTER_TABLE (Cost=26346 Card=11171690 Bytes=368665770)
Example data can be viewed on previous post ( link above ). The only index on this table is on Processing_date which is not referenced ( nor relevant as a limit to this query ).
d.
One option could be
SELECT * FROM
(select min(decode(ACC_CODE,91,SAL
decode(ACC_CODE,92,DELIVER
from TABLE
where ACC_CODE in (91,92))
WHERE DELIVERY_DATE IS NOT NULL
If ACC_CODE is indexed, then you should get a table access by index, rather than a full table scan or if the table is partitioned by ACC_CODE then you should get only the required partitions being scanned
Business Accounts
Answer for Membership
by: gatorvipPosted on 2007-07-09 at 09:29:48ID: 19446519
What does your explain plan say? What indexes do you have? What is "far too long"?