Home » RDBMS Server » Performance Tuning » Unable to interpret number of rows accessed during Full Table scan (Oracle Enterprise Edition 11.2.0.4.0 on Linux)
Unable to interpret number of rows accessed during Full Table scan [message #642949] |
Wed, 23 September 2015 07:13 |
|
orapratap
Messages: 134 Registered: November 2011 Location: Canada
|
Senior Member |
|
|
Hello
I have some confusion while interpreting execution plan and would seek your help on the same
Regardless of 'Full Table Scan' or 'Index Access' the execution plan shows same numbers of rows accessed
Am I missing some basic stuff?
Here is the example
Before creating the Index
**************************************************
**************************************************
SQL> create table TS as select * from dba_objects;
SQL> exec dbms_stats.gather_table_stats(user,'TS');
PL/SQL procedure successfully completed.
SQL> select COLUMN_NAME,NUM_DISTINCT,NUM_NULLS from dba_tab_columns where table_name='TS';
COLUMN_NAME NUM_DISTINCT NUM_NULLS
------------------------------ ------------ ----------
M 0 0
N 0 0
EDITION_NAME 0 92329
NAMESPACE 21 1
SECONDARY 2 0
GENERATED 2 0
TEMPORARY 2 0
STATUS 2 0
TIMESTAMP 1912 1
LAST_DDL_TIME 1806 1
CREATED 1723 0
OBJECT_TYPE 46 0
DATA_OBJECT_ID 12827 79408
OBJECT_ID 92329 1
SUBOBJECT_NAME 417 91414
OBJECT_NAME 54896 0
OWNER 88 0
17 rows selected.
SQL> select num_rows from dba_tables where table_name='TS';
NUM_ROWS
----------
92329
SQL> explain plan for select * from ts where object_name='EMP';
Explained.
SQL> select * from table(dbms_xplan.display(null,null,'all'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 338975713
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 196 | 368 (1)| 00:00:05 |
|* 1 | TABLE ACCESS FULL| TS | 2 | 196 | 368 (1)| 00:00:05 |
--------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 - SEL$1 / TS@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_NAME"='EMP')
Column Projection Information (identified by operation id):
-----------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 - "TS"."OWNER"[VARCHAR2,30], "OBJECT_NAME"[VARCHAR2,128],
"TS"."SUBOBJECT_NAME"[VARCHAR2,30], "TS"."OBJECT_ID"[NUMBER,22],
"TS"."DATA_OBJECT_ID"[NUMBER,22], "TS"."OBJECT_TYPE"[VARCHAR2,19],
"TS"."CREATED"[DATE,7], "TS"."LAST_DDL_TIME"[DATE,7],
"TS"."TIMESTAMP"[VARCHAR2,19], "TS"."STATUS"[VARCHAR2,7],
"TS"."TEMPORARY"[VARCHAR2,1], "TS"."GENERATED"[VARCHAR2,1],
"TS"."SECONDARY"[VARCHAR2,1], "TS"."NAMESPACE"[NUMBER,22],
"TS"."EDITION_NAME"[VARCHAR2,30]
After creating the Index
**************************************************
**************************************************
SQL> create index i_objname on ts(object_name);
Index created.
SQL> exec dbms_stats.gather_index_stats(user,'I_OBJNAME');
PL/SQL procedure successfully completed.
SQL> explain plan for select * from ts where object_name='EMP';
Explained.
SQL> select * from table(dbms_xplan.display(null,null,'all'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3000387531
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 196 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TS | 2 | 196 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | I_OBJNAME | 2 | | 3 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------
1 - SEL$1 / TS@SEL$1
2 - SEL$1 / TS@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_NAME"='EMP')
Column Projection Information (identified by operation id):
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------
1 - "TS"."OWNER"[VARCHAR2,30], "OBJECT_NAME"[VARCHAR2,128],
"TS"."SUBOBJECT_NAME"[VARCHAR2,30], "TS"."OBJECT_ID"[NUMBER,22],
"TS"."DATA_OBJECT_ID"[NUMBER,22], "TS"."OBJECT_TYPE"[VARCHAR2,19],
"TS"."CREATED"[DATE,7], "TS"."LAST_DDL_TIME"[DATE,7],
"TS"."TIMESTAMP"[VARCHAR2,19], "TS"."STATUS"[VARCHAR2,7],
"TS"."TEMPORARY"[VARCHAR2,1], "TS"."GENERATED"[VARCHAR2,1],
"TS"."SECONDARY"[VARCHAR2,1], "TS"."NAMESPACE"[NUMBER,22],
"TS"."EDITION_NAME"[VARCHAR2,30]
2 - "TS".ROWID[ROWID,10], "OBJECT_NAME"[VARCHAR2,128]
SQL> select /*+ gather_plan_statistics */ * from ts where object_name='EMP';
SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 10593djpbmayc, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from ts where object_name='EMP'
Plan hash value: 3000387531
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 8 |00:00:00.01 | 12 |
| 1 | TABLE ACCESS BY INDEX ROWID| TS | 1 | 2 | 8 |00:00:00.01 | 12 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|* 2 | INDEX RANGE SCAN | I_OBJNAME | 1 | 2 | 8 |00:00:00.01 | 4 |
---------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_NAME"='EMP')
Thus looks like in both above plans, FTS as well as Index scan plan, 2 rows are accessed
Only the Predicate info changed from
1 - filter("OBJECT_NAME"='EMP')
to
2 - access("OBJECT_NAME"='EMP')
But during FTS haven't all rows were accessed to filter out 2 rows?
Why I can't see the number of rows accessed to get 2 rows?
Kind Regards
Orapratap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Unable to interpret number of rows accessed during Full Table scan [message #643075 is a reply to message #643069] |
Mon, 28 September 2015 06:43 |
|
Kevin Meade
Messages: 2103 Registered: December 1999 Location: Connecticut USA
|
Senior Member |
|
|
In my experience, it is near impossible to tune a query without access to the underlying data. This means either access to some version of the database that exhibits the problem be it either the original database or a copy somewhere. If all you have is a query plan, then all you can do is guess. Good luck in such a case.
Thanks for looking at the attachments. Kevin
|
|
|
Goto Forum:
Current Time: Thu Jan 30 13:25:04 CST 2025
|