Home » RDBMS Server » Performance Tuning » Query regarding tkprof output and cardinality in it (Oracle 10g R2 on REHL)
Query regarding tkprof output and cardinality in it [message #490352] Mon, 24 January 2011 04:50 Go to next message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Please refer the following sqls and the results of the trace

As we can see in the plan 'TABLE ACCESS FULL T1' is the first step in the execution of the query

While we have set the num rows to 1000000 why we can't see them in the plan and instead it is showing only 10 rows

Also why I am unable to see cardinality in the plan

I have checked the statistic setting
timed_statistics                     boolean     TRUE
statistics_level                     string      TYPICAL


create table t1 as select 1 x, level y from dual connect by level <= 10;

create table t2 (x int primary key, z int );

insert into t2 values ( 1, 0 );

exec dbms_stats.set_table_stats( user, 'T1', numrows => 1000000, numblks => 10000 );

exec dbms_stats.set_table_stats( user, 'T2', numrows => 1000000, numblks => 10000 );


Then I executed following query
select /*+ first_rows(10) */ *  from t1, t2   where t1.x = t2.x;


and below is the related trace

select /*+ first_rows(10) */ *
      from t1, t2
     where t1.x = t2.x

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.02          0          9          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.00          1         16          0          10
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.00       0.02          1         25          0          10

Misses in library cache during parse: 1
Optimizer mode: FIRST_ROWS
Parsing user id: 5

Rows     Row Source Operation
-------  ---------------------------------------------------
     10  NESTED LOOPS  (cr=16 pr=1 pw=0 time=200 us)
     10   TABLE ACCESS FULL T1 (cr=4 pr=1 pw=0 time=193 us)
     10   TABLE ACCESS BY INDEX ROWID T2 (cr=12 pr=0 pw=0 time=153 us)
     10    INDEX UNIQUE SCAN SYS_C0096225 (cr=2 pr=0 pw=0 time=80 us)(object id 4669518)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  db file sequential read                         1        0.00          0.00
  SQL*Net message from client                     2        9.31          9.31
********************************************************************************



Regards,
OraKaran
Re: Query regarding tkprof output and cardinality in it [message #490367 is a reply to message #490352] Mon, 24 January 2011 05:19 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
The plan given by tkprof is the ACTUAL executed plan and so the figures are the real ones not estimated ones as for an explain plan (or explain option of tkprof).

Regards
Michel
Re: Query regarding tkprof output and cardinality in it [message #490373 is a reply to message #490367] Mon, 24 January 2011 05:36 Go to previous messageGo to next message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Michel

Thanks for the quick reply

It is not clear to me

1)Do you mean actual plan overlooks the stats set by dbms_stat.set_table_stats?
And because of this the table T1 which is Fully scanned as a first step will show acual rows scanned regardless of whatever we set?

2) Why I am unable to see "card" in "row source generation"?

Regards,
OraKaran
Re: Query regarding tkprof output and cardinality in it [message #490377 is a reply to message #490373] Mon, 24 January 2011 05:47 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
1) I mean what it gives is what has been executed. Just that. Statistics do not matter there, TKPROF only displays what it finds in the trace file; open it and you will see the same thing in line named STAT

2) Because it is something the runtime has not at parse time. Remember, here you have the reality not an estimation.

Regards
Michel
Re: Query regarding tkprof output and cardinality in it [message #490401 is a reply to message #490352] Mon, 24 January 2011 08:07 Go to previous message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Thanks Michel

Got it now

Regards,
OraKaran
Previous Topic: Database Links
Next Topic: db sequential read (merged)
Goto Forum:
  


Current Time: Fri Nov 22 02:04:55 CST 2024