Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Mansi.

Asked: March 21, 2017 - 7:39 am UTC

Last updated: March 25, 2017 - 3:28 am UTC

Version: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0

Viewed 10K+ times! This question is

You Asked

Hi Team,

Not able to understand few thing while running SQL. I am running SQL,in which there is full scan table with around 7 million records.
and if I check gv$sql,it has high number if IO. almost around 100 millions.

My question is:

1. I can see 3 queries are running on DB of same sort,consuming more IOs and returning no row. It keep executing. Does large IO consume all shared pool area and make application slow? (because I faced application slow issue in other application due to large IO,but it was not as large as 100 millions,it was in thousands only,still I faced increased inactive session and need to bounce application server instance.) But i didnt face such issue in this application.

2. Not able to understand connection between buffer gets and SGA and application slowness issue.


and Connor said...

v$sql is *cumulative* data, so you need to check the EXECUTION columns as well.


SQL> drop table t purge;

Table dropped.

SQL> create table t as select * from dba_objects;

Table created.

SQL>
SQL>
SQL> select max(created) from t;

MAX(CREAT
---------
23-MAR-17

1 row selected.

SQL> select executions, buffer_gets from v$sql
  2  where sql_text like 'select max(created)%';

EXECUTIONS BUFFER_GETS
---------- -----------
         1        1529

1 row selected.

SQL>
SQL> select max(created) from t;

MAX(CREAT
---------
23-MAR-17

1 row selected.

SQL> select max(created) from t;

MAX(CREAT
---------
23-MAR-17

1 row selected.

SQL> select max(created) from t;

MAX(CREAT
---------
23-MAR-17

1 row selected.

SQL> select max(created) from t;

MAX(CREAT
---------
23-MAR-17

1 row selected.

SQL> select max(created) from t;

MAX(CREAT
---------
23-MAR-17

1 row selected.

SQL>
SQL> select executions, buffer_gets from v$sql
  2  where sql_text like 'select max(created)%';

EXECUTIONS BUFFER_GETS
---------- -----------
         6        9129

1 row selected.

SQL>
SQL>
SQL>


To answer your questions

1) The number of rows *returned* doesnt really have a bearing here. If I query a 1 billion row table, and get no rows back...I still scanned 1 billion rows.

Large I/O typically does not consume the buffer cache, because if we think a large scan is needed, we'll do what is called a "direct read" which comes from the files directly to the private area for your session and bypasses the buffer cache. Even if its a small object (but still "largish") blocks that are read rarely are quickly aged out of the buffer cache, whilst more active blocks are retained.

2) There isnt really a direct link except in terms of a more simple one, namely "effort". If you have to consume a lot of resources (physical IO, or buffer gets, or CPU or anything else that is a limited resource) when running SQL, then whoever or whatever is running that SQL will probably experience this as slowness.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks so much

Mansi Raval, March 24, 2017 - 7:22 am UTC

I went through some different behaviour of query too. One query running good for few input parameter but got hang on some of the input parameter.
Not exactly hung,but it keeps running and consuming large number of IOs and returning nothing.


Milind

Milind, March 24, 2017 - 1:53 pm UTC

"Large I/O typically does not consume the buffer cache"

1. From where can I find whether direct I/O (PGA) is used or Buffer cache I/Os?
2. If query is working on single table (accessing number of data blocks) and needs to perform FTS, will it be always performed using direct I/O?

Thanks in advance.


Connor McDonald
March 25, 2017 - 3:28 am UTC

If you trace a session you'll see wait events which describe what is happening:

'direct path read' - we bypassed the buffer cache
'db file scattered read' - we used the buffer cache

Also, the session level statistics give some information as well, via

physical reads
physical reads direct

The decision as to whether to go direct or not is based on a number of things. Here's a nice little blog entry on it

http://blog.tanelpoder.com/2012/09/03/optimizer-statistics-driven-direct-path-read-decision-for-full-table-scans-_direct_read_decision_statistics_driven/