Home » RDBMS Server » Performance Tuning » how to check whether index is rebuilt or not?
how to check whether index is rebuilt or not? [message #115302] |
Fri, 08 April 2005 20:51  |
confident
Messages: 28 Registered: March 2005
|
Junior Member |
|
|
i faced the interview for junior dba position, the interview ask me this quesiton
1.how to know the whether particular index is rebuilt or not and size of index. and how to know to what type of index it was..
2. user running a sql queries, by his queries, how to know, whether his queries using index or not...and what type index is using.... i replied to this answer, through explain plan we can know... is it right? if it right, please tell me, how to know from explain plain..
if u have any performance tunning interview question please forward to this mail id confident119@yahoo.com.sg...i will be very grate ful to him..
|
|
|
|
|
|
|
|
|
Re: how to check whether index is rebuilt or not? [message #115661 is a reply to message #115619] |
Wed, 13 April 2005 09:06  |
pscjhe
Messages: 38 Registered: April 2005
|
Member |
|
|
Doesn't "truncate table" truncate indexes as well ? Look at this.
tch@TCHTST2> create index t_ndx on t(object_id);
Index created.
tch@TCHTST2> select blocks from dba_segments where segment_name='T_NDX';
BLOCKS
----------
65
tch@TCHTST2> truncate table t;
Table truncated.
tch@TCHTST2> select blocks from dba_segments where segment_name='T_NDX';
BLOCKS
----------
13
dba_objects is only a synonym to all_objects. If you look at the source code of all_objects ( too long to include here), you will see last_ddl_time is from sys.obj$.mtime. So it seems to mean "modification" time. So it is not exactly when "alter index rebuild" is run. it is close enough. If you really have to trace when this DDL is run, you have to audit or use event trigger.
As to tkprof, I am sorry that I didn't make it clear enough to mean "Row Source Operation", which is the history of what was used to execute the sql and INCLUDED in the trace file. However, explain plan, autotrace, tkprof explain=u/p, no matter when they are executed, they are subject to any change in between execution and do this explain plan. Hence not 100% accurate. But in reality they are almost always same as tkprof's Row source.
In 9i, v$sql_plan also includes the plan that is the history that comes with sql execution. There is detailed method using this in Tom Kyte's "Effective Oracle By Design" Book p91.
Look at this tkprof
------------------------------------------------------------
select *
from
t where value='aa'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 3 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 3 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 6447 (TCH)
Rows Row Source Operation
------- ---------------------------------------------------
1 TABLE ACCESS BY INDEX ROWID T (cr=3 r=0 w=0 time=40 us)
1 INDEX RANGE SCAN T_NDX (cr=2 r=0 w=0 time=27 us)(object id 43075)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT GOAL: CHOOSE
1 TABLE ACCESS (BY INDEX ROWID) OF 'T'
1 INDEX (RANGE SCAN) OF 'T_NDX' (NON-UNIQUE)
....
-----------------------------------------------------
The first one is Row source Operation and second one is explain plan. Normally you NEVER use explain plan in tkprof at all.
-----------------------------------------------------
|
|
|
Goto Forum:
Current Time: Thu May 01 14:49:13 CDT 2025
|