dbTalk Databases Forums  

TABLE ACCESS FULL

comp.databases.oracle.server comp.databases.oracle.server


Discuss TABLE ACCESS FULL in the comp.databases.oracle.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jay
 
Posts: n/a

Default TABLE ACCESS FULL - 10-22-2003 , 03:19 PM






I'm trying to speed up my query which selects only 30 records out of
3million records.
All my conditions are indexed but when I explains it, it says TABLE ACCESS
FULL.
I use "between" and, it seemingly, when I reduce range of "between" then it
does INDEX RANGE SCAN.

Is there anyway I can force to do INDEX RANGE SCAN?
Thanks.
-Jay







Reply With Quote
  #2  
Old   
Bricklen
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-22-2003 , 03:28 PM






Jay wrote:

Quote:
I'm trying to speed up my query which selects only 30 records out of
3million records.
All my conditions are indexed but when I explains it, it says TABLE ACCESS
FULL.
I use "between" and, it seemingly, when I reduce range of "between" then it
does INDEX RANGE SCAN.

Is there anyway I can force to do INDEX RANGE SCAN?
Thanks.
-Jay

post your oracle version and query. Also, what are
optimizer_index_caching and optimizer_index_cost_adj set to?
Have you analyzed the relevant tables/indexes?



Reply With Quote
  #3  
Old   
Domenic G.
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-22-2003 , 08:08 PM



select /*+ index(table_name index_name */ rest of your query ...

domenic.

"Jay" <no (AT) spam (DOT) com> wrote

Quote:
I'm trying to speed up my query which selects only 30 records out of
3million records.
All my conditions are indexed but when I explains it, it says TABLE ACCESS
FULL.
I use "between" and, it seemingly, when I reduce range of "between" then it
does INDEX RANGE SCAN.

Is there anyway I can force to do INDEX RANGE SCAN?
Thanks.
-Jay

Reply With Quote
  #4  
Old   
Geomancer
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-22-2003 , 09:14 PM



Quote:
Is there anyway I can force to do INDEX RANGE SCAN?
1- Use an index hint. Build an index on the columns in youtr WHERE
clause and add a hint to the query.

2 - Set optimizer_index_cost_adj=10

3 - Add a rule hint. Rule will always use an index.


Reply With Quote
  #5  
Old   
Billy Verreynne
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-23-2003 , 12:39 AM



"Jay" <no (AT) spam (DOT) com> wrote

Quote:
I'm trying to speed up my query which selects only 30 records out of
3million records.
All my conditions are indexed but when I explains it, it says TABLE ACCESS
FULL.
The view that a Full Table Scan (FTS) is a bad thing.. is nothing but
an OWT (old wifes' tale).

If the cost of using indexes is bigger than using a FTS, then Oracle
will use a FTS.

Quote:
I use "between" and, it seemingly, when I reduce range of "between" then it
does INDEX RANGE SCAN.
Exactly!!! And there you have stated WHY there is a difference in
execution plan. Pity that you did not spend some time thinking this
through as you would have arrived at the answer.

Simple scenario. I have a 3GB index. I do a select with a BETWEEN
clause.

Case 1. The value range specified in the between clause covers 2GB of
data in that index (e.g. WHERE surname BETWEEN 'A' AND 'RZ')

Case 2. The value range specified covers 10MB of index data (e.g.
WHERE surname BETWEEN 'SMITH' AND 'SMYTHE')


Now look at this from the work that the database needs to do.

In case 1, the db looks at this as says "hmm.. you are covering 80% of
all index values. That means that 80% or even more of the data in the
table will satisfy the criteria."

Thus the database, being the clever bugger it is (unlike what many
seems to think), decides NOT to use the index.

80% of the data in the table will match the criteria. So instead of
reading 80% of the index followed by reading 80% of the table, it
rather reads 100% of the table and not use the index at all. (80%
being an example - the actual percentage value is indexes & tables
specific)

Q. what is the most expensive operation in a database?
A. I/O

Case 2. The exact opposite of case 1. Thus the index IS used.


You have proved two things.
a) Oracle CBO works as it should (and better than you thought)
b) You could spend some more time with the Oracle manuals :-)


Quote:
Is there anyway I can force to do INDEX RANGE SCAN?
IMO never ever enforce an index range scan (yes it is possible using
hints). Index range scans can be a lot more painful than a FTS. When
dealing with unknown index ranges, let the database (i.e. CBO)
decides.

--
Billy


Reply With Quote
  #6  
Old   
Noons
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-23-2003 , 04:46 AM



"Billy Verreynne" <vslabs (AT) onwe (DOT) co.za> wrote



Quote:
Case 2. The exact opposite of case 1. Thus the index IS used.
Like he said: he's doing case 2 (30 rows out of 3 million)
and the optimizer is NOT picking the index...
In the chapter about indexes in Expert oneonone, TK goes
at length under which conditions using an index is or is
not better than doing a FTS. With examples. Worth a look.

Quote:
You have proved two things.
a) Oracle CBO works as it should (and better than you thought)
Maybe not in his case?

Quote:
b) You could spend some more time with the Oracle manuals :-)
TK's book for one helps in these situations.


Quote:
IMO never ever enforce an index range scan (yes it is possible using
hints). Index range scans can be a lot more painful than a FTS. When
dealing with unknown index ranges, let the database (i.e. CBO)
decides.
His words:

Quote:
I'm trying to speed up my query which selects only 30 records out of
3million records.
In anyone's book that is not an unknown index range...
I agree though: WHEN dealing with *unknown* ranges, then
it's better to let the CBO do its work. If it tends to err
on the side of pessimism, it's always possible to
nudge it in the right direction with the "optimizer_*"
stuff. That is of course the general case.

OT: waddyareckon: Boks, AllBlacks or the Poms?

--
Cheers
Nuno Souto
wizofoz2k (AT) yahoo (DOT) com.au.nospam




Reply With Quote
  #7  
Old   
Niall Litchfield
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-23-2003 , 07:51 AM



Can you post the query and the explain? I can think of a number of reasons
why your index might not be being used, but you don't give sufficient
information as to why.



--
Niall Litchfield
Oracle DBA
Audit Commission Uk
"Jay" <no (AT) spam (DOT) com> wrote

Quote:
I'm trying to speed up my query which selects only 30 records out of
3million records.
All my conditions are indexed but when I explains it, it says TABLE ACCESS
FULL.
I use "between" and, it seemingly, when I reduce range of "between" then
it
does INDEX RANGE SCAN.

Is there anyway I can force to do INDEX RANGE SCAN?
Thanks.
-Jay









Reply With Quote
  #8  
Old   
Billy Verreynne
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-23-2003 , 02:05 PM



"Noons" <wizofoz2k (AT) yahoo (DOT) com.au.nospam> wrote

Quote:
Like he said: he's doing case 2 (30 rows out of 3 million)
and the optimizer is NOT picking the index..
Yeah, I did see that "30 rows being returned/selected", but I was
thinking group by was neglected to be mentioned.

Well either that, or the CBO is seriously screwy when deciding FTS to
do only 30 rows. The latter I will only believe when hard evidence is
given. :-)

Quote:
In the chapter about indexes in Expert oneonone, TK goes
at length under which conditions using an index is or is
not better than doing a FTS.
Yep. Total coincidence. The Book is right here next to the keyboard.
:-)

Just a pity that he did not add to the myths that FTSs are not evil.
I've seen a lot of frustration and tuning by people who sees a FTS in
an execution plan and immediately go "holy crap!" and then start
swinging away at the problem with index hints. Instead the warning
bells should go as a FTS implies that you want to hit big volumes with
your SQL.

Quote:
In anyone's book that is not an unknown index range...
I agree though: WHEN dealing with *unknown* ranges, then
it's better to let the CBO do its work. If it tends to err
on the side of pessimism, it's always possible to
nudge it in the right direction with the "optimizer_*"
stuff. That is of course the general case.
Agree. That is IF the statement on 30 rows being selected ALSO implies
that these are also *only* 30 rows (of the millions) being processed.
And in the absense of more detail, I cannot see that to be the case
when the CBO decides to do a FTS.

Quote:
OT: waddyareckon: Boks, AllBlacks or the Poms?
Tough one. Of course I'm hoping for the Boks. The Poms are damn good,
but the longer you're on the top, the more difficult it becomes to
stay there. I do not think that they can keep up that level of play
consistently for such a long time. They have everything to lose and
little to gain. Not forgetting the Kiwis either. They have a good
team. And then there's the mightly AllBlacks... So the heart says
Bokke but the brain says mebbe the AllBlacks.

Besides, us southern hemisphere okes have to stand together. :-)

--
Billy


Reply With Quote
  #9  
Old   
Niall Litchfield
 
Posts: n/a

Default Re: TABLE ACCESS FULL - 10-23-2003 , 03:47 PM



"Billy Verreynne" <vslabs (AT) onwe (DOT) co.za> wrote

Quote:
"Noons" <wizofoz2k (AT) yahoo (DOT) com.au.nospam> wrote

Like he said: he's doing case 2 (30 rows out of 3 million)
and the optimizer is NOT picking the index..

Yeah, I did see that "30 rows being returned/selected", but I was
thinking group by was neglected to be mentioned.

Well either that, or the CBO is seriously screwy when deciding FTS to
do only 30 rows. The latter I will only believe when hard evidence is
given. :-)
One of the scenarios I suspect is that the data is seriously skewed and
there are no histogram stats. (Or alternatively bind variables are being
used in a skewed case). 30 Rows out of 3m have a status of 'UNKNOWN' but as
the table only has 3 distinct values for status 'PROCESSED','UNPROCESSED'
and 'UNKNOWN' the optimizer thinks that it will pick a 3rd of the table with
the condition AND STATUS='UNKNOWN'.

<snip on topic stuff>

Quote:
Agree. That is IF the statement on 30 rows being selected ALSO implies
that these are also *only* 30 rows (of the millions) being processed.
And in the absense of more detail, I cannot see that to be the case
when the CBO decides to do a FTS.

OT: waddyareckon: Boks, AllBlacks or the Poms?

Tough one. Of course I'm hoping for the Boks. The Poms are damn good,
but the longer you're on the top, the more difficult it becomes to
stay there. I do not think that they can keep up that level of play
consistently for such a long time. They have everything to lose and
little to gain. Not forgetting the Kiwis either. They have a good
team. And then there's the mightly AllBlacks... So the heart says
Bokke but the brain says mebbe the AllBlacks.

Besides, us southern hemisphere okes have to stand together. :-)
yeah that's what I saw in SA all the SA guys I met standing shoulder to
shoulder with the Aussies FWIW I see England winning the competition in a
tough fight with NZ in the final. And then collapsing for the next 10 years.

And another thing I fly 6000 miles to SA and there's no bloody southern
cross or any constellation at all to see in the night sky. Talk about a let
down. sheesh.


--
Niall Litchfield
Oracle DBA
Audit Commission UK
*****************************************
Please include version and platform
and SQL where applicable
It makes life easier and increases the
likelihood of a good answer
******************************************




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.