I have a table with 999 rows in 24 blocks.Ran a sql query for the first time which does a full table scan.From the execution statistics it shows 87 LIOS I'm confused why LIOS is high it's like Oracle is reading all blocks close to 3 times
Here arraysize is 500
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> select num_rows,blocks,empty_blocks from user_tables
2 where table_name like 'SALE_TAB';
NUM_ROWS BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
999 24 0
SQL> @x
Display execution plan for last statement for this session from library cache...
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID ap1xwwqvvbfyd, child number 0
-------------------------------------
select * from sale_tab
Plan hash value: 2430023251
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| A-Rows | A-Time | Buffers | Reads |
----------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 8 (100)| 999 |00:00:00.02 | 25 | 21 |
| 1 | TABLE ACCESS FULL| SALE_TAB | 1 | 999 | 91908 | 8 (0)| 999 |00:00:00.02 | 25 | 21 |
----------------------------------------------------------------------------------------------------------------------
13 rows selected.
SQL> @sql_id ap1xwwqvvbfyd %
Show SQL text, child cursors and execution stats for SQLID ap1xwwqvvbfyd child %
HASH_VALUE CH# SQL_TEXT
---------- ---- ------------------------------------------------------------------------------------------------------------------------------------------------------
3082140621 0 select * from sale_tab
CH# PARENT_HANDLE OBJECT_HANDLE PLAN_HASH PARSES H_PARSES EXECUTIONS FETCHES ROWS_PROCESSED CPU_MS ELA_MS LIOS PIOS SORTS USERS_EXECUTING
---- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- -------------- ---------- ---------- ---------- ---------- ---------- ---------------
0 00007FFD911A4238 00007FFD9C847038 2430023251 1 1 1 3 999 15.625 37.842 87 22 0 0
Best Answer
Because the database has to run additional recursive queries the first time it encounters a query, to parse it. It has to check if the given SQL is valid, it has to check the optimizer statistics, etc.
We can clearly see from the plan statistics that it required a single buffer get, yet
V$SQL
shows 220. But now the query is parsed, if I run it again, buffer gets are increased only by the amount the query really uses:If you are interested what additional SQLs the database executes when parsing the query, you can enable SQL tracing and view the trace file: