473,414 Members | 1,596 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,414 software developers and data experts.

Query using full table scan

Hi,
Can anybody let me know how I can optimise following Query.

Select * from reports
where
( exists ( SELECT 1 FROM results_required rr, item_claims_trials ict, results res
WHERE ict.t_t_id IN ( 3725 )
and res.rr_rr_id = rr.rr_id
AND rr.rt_rt_id = -1
and rr.ict_ict_id = ict.ict_id
and ( NVL( res.res_res_id_refers_to, res.res_id ) = report_id )
)
);

Explain Plan for this is as below:

SELECT STATEMENT Optimizer=CHOOSE (Cost=4589774 Card=208129 Bytes=31635608)
__FILTER
____HASH JOIN (OUTER) (Cost=10936 Card=208129 Bytes=31635608)
______HASH JOIN (Cost=8079 Card=14631 Bytes=2062971)
________NESTED LOOPS (OUTER) (Cost=6499 Card=10734 Bytes=1116336)
__________NESTED LOOPS (OUTER) (Cost=459 Card=755 Bytes=50585)
____________HASH JOIN (OUTER) (Cost=35 Card=53 Bytes=2968)
______________HASH JOIN (OUTER) (Cost=26 Card=53 Bytes=2226)
________________HASH JOIN (OUTER) (Cost=17 Card=53 Bytes=1484)
__________________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=53 Bytes=742)
____________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=53)
__________________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=47 Bytes=658)
____________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=3)
________________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=47 Bytes=658)
__________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=3)
______________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=47 Bytes=658)
________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=3)
____________TABLE ACCESS (BY INDEX ROWID) OF RESULTS (Cost=8 Card=14 Bytes=154)
______________INDEX (RANGE SCAN) OF RES_RR_FK_I (NON-UNIQUE) (Cost=2 Card=14)
__________TABLE ACCESS (BY INDEX ROWID) OF RESULTS (Cost=8 Card=14 Bytes=518)
____________INDEX (RANGE SCAN) OF RES_RR_FK_I (NON-UNIQUE) (Cost=2 Card=14)
________TABLE ACCESS (FULL) OF RESULTS (Cost=1385 Card=72363 Bytes=2677431)
______TABLE ACCESS (FULL) OF RESULTS (Cost=1385 Card=1483628 Bytes=16319908)
____TABLE ACCESS (BY INDEX ROWID) OF RESULTS (Cost=8 Card=1 Bytes=13)
______NESTED LOOPS (Cost=22 Card=1 Bytes=35)
________NESTED LOOPS (Cost=13.2024962378238 Card=1 Bytes=22)
__________TABLE ACCESS (BY INDEX ROWID) OF ITEM_CLAIMS_TRIALS (Cost=2 Card=9 Bytes=72)
____________INDEX (RANGE SCAN) OF ICT_T_FK_I (NON-UNIQUE) (Cost=1 Card=9)
__________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=13.2024962378238 Card=1 Bytes=14)
____________BITMAP CONVERSION (TO ROWIDS)
______________BITMAP AND
________________BITMAP CONVERSION (FROM ROWIDS)
__________________INDEX (RANGE SCAN) OF RR_ICT_FK_I (NON-UNIQUE)
________________BITMAP CONVERSION (FROM ROWIDS)
__________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE)
________INDEX (RANGE SCAN) OF RES_RR_FK_I (NON-UNIQUE) (Cost=2 Card=14)


==================================
Thanks.
==================================
May 25 '07 #1
1 2689
chandu031
78 Expert
Hi,
Can anybody let me know how I can optimise following Query.

Select * from reports
where
( exists ( SELECT 1 FROM results_required rr, item_claims_trials ict, results res
WHERE ict.t_t_id IN ( 3725 )
and res.rr_rr_id = rr.rr_id
AND rr.rt_rt_id = -1
and rr.ict_ict_id = ict.ict_id
and ( NVL( res.res_res_id_refers_to, res.res_id ) = report_id )
)
);

Explain Plan for this is as below:

SELECT STATEMENT Optimizer=CHOOSE (Cost=4589774 Card=208129 Bytes=31635608)
__FILTER
____HASH JOIN (OUTER) (Cost=10936 Card=208129 Bytes=31635608)
______HASH JOIN (Cost=8079 Card=14631 Bytes=2062971)
________NESTED LOOPS (OUTER) (Cost=6499 Card=10734 Bytes=1116336)
__________NESTED LOOPS (OUTER) (Cost=459 Card=755 Bytes=50585)
____________HASH JOIN (OUTER) (Cost=35 Card=53 Bytes=2968)
______________HASH JOIN (OUTER) (Cost=26 Card=53 Bytes=2226)
________________HASH JOIN (OUTER) (Cost=17 Card=53 Bytes=1484)
__________________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=53 Bytes=742)
____________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=53)
__________________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=47 Bytes=658)
____________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=3)
________________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=47 Bytes=658)
__________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=3)
______________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=8 Card=47 Bytes=658)
________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE) (Cost=1 Card=3)
____________TABLE ACCESS (BY INDEX ROWID) OF RESULTS (Cost=8 Card=14 Bytes=154)
______________INDEX (RANGE SCAN) OF RES_RR_FK_I (NON-UNIQUE) (Cost=2 Card=14)
__________TABLE ACCESS (BY INDEX ROWID) OF RESULTS (Cost=8 Card=14 Bytes=518)
____________INDEX (RANGE SCAN) OF RES_RR_FK_I (NON-UNIQUE) (Cost=2 Card=14)
________TABLE ACCESS (FULL) OF RESULTS (Cost=1385 Card=72363 Bytes=2677431)
______TABLE ACCESS (FULL) OF RESULTS (Cost=1385 Card=1483628 Bytes=16319908)
____TABLE ACCESS (BY INDEX ROWID) OF RESULTS (Cost=8 Card=1 Bytes=13)
______NESTED LOOPS (Cost=22 Card=1 Bytes=35)
________NESTED LOOPS (Cost=13.2024962378238 Card=1 Bytes=22)
__________TABLE ACCESS (BY INDEX ROWID) OF ITEM_CLAIMS_TRIALS (Cost=2 Card=9 Bytes=72)
____________INDEX (RANGE SCAN) OF ICT_T_FK_I (NON-UNIQUE) (Cost=1 Card=9)
__________TABLE ACCESS (BY INDEX ROWID) OF RESULTS_REQUIRED (Cost=13.2024962378238 Card=1 Bytes=14)
____________BITMAP CONVERSION (TO ROWIDS)
______________BITMAP AND
________________BITMAP CONVERSION (FROM ROWIDS)
__________________INDEX (RANGE SCAN) OF RR_ICT_FK_I (NON-UNIQUE)
________________BITMAP CONVERSION (FROM ROWIDS)
__________________INDEX (RANGE SCAN) OF RR_RT_FK_I (NON-UNIQUE)
________INDEX (RANGE SCAN) OF RES_RR_FK_I (NON-UNIQUE) (Cost=2 Card=14)


==================================
Thanks.
==================================

Hi,

Have you collected the statistics on this table?
May 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mahesh Hardikar | last post by:
Hi , Oracle 8.1.7.0.0 on HP-UX 11.0 I am a newbie as far as PL-SQL is concerned . I have Sybase/MSSQL T-SQL background. We have a report which uses a select statement . This select...
3
by: hrishy | last post by:
Hi All I have the following query to be tuned.. Select distinct PA.PersonAddress_IDX, AT.Name AddressType, A.Line1 Address1, A.Line2 Address2, A.City, A.State, A.County, A.Country,...
2
by: Pramod Ramachandran | last post by:
Hi group, I have a query as follows. SELECT * FROM ACS$USG_EVENT, ACS$USG_EVENTDETAIL WHERE ACS$USG_EVENTDETAIL.PARENTCANONICALID = ACS$USG_EVENT.CANONICALID; both the tables are analyzed...
6
by: Steven D.Arnold | last post by:
I have a query which does not use column indexes that it should use. I have discovered some interesting behaviors of Postgres which may indicate a bug in the database's query planning. Take a...
7
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
2
by: Zygo Blaxell | last post by:
I have a table with a few million rows of temperature data keyed by timestamp. I want to group these rows by timestamp intervals (e.g. every 32 seconds), compute aggregate functions on the...
25
by: frizzle | last post by:
Hi there, I have a mySQL system with a news publishing part in it: Admins can create new items with text in it, and they have an option to create 'fulltexts', so you'd get "read more ..." on the...
6
by: ymrmcm | last post by:
Hi all, Iam trying to run below query, its taking lot of time . query: SELECT LN.STORE_CD, LN.LOC_CD, LN.DEL_DOC_NUM, LN.DEL_DOC_LN#, LN.ITM_CD, LN.QTY*100, LN.OUT_CD,...
1
by: deepu03 | last post by:
Hi All I have the following query to be tuned.. SELECT distinct a.EMPLID ,a.PER_ORG ,a.HIRE_DT ,a.grade
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.