Reduce Logical IO [db block gets/consistent gets]

Hi,
Still I'm unsure about the Logical IO (db block gets + consistent gets).
I want to reduce 'consistent gets' for this query
SQL> set autotrace traceonly
SQL> select * from cm_per_phone_vw;
905 rows selected.
Execution Plan
Plan hash value: 524433310
| Id  | Operation                    | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT             |              |   868 | 38192 |     8   (0)| 00:00:01 |
|   1 |  SORT GROUP BY NOSORT        |              |   868 | 38192 |     8   (0)| 00:00:01 |
|   2 |   TABLE ACCESS BY INDEX ROWID| CI_PER_PHONE |  1238 | 54472 |     8   (0)| 00:00:01 |
|   3 |    INDEX FULL SCAN           | CM172C0      |  1238 |       |     1   (0)| 00:00:01 |
Statistics
          8  recursive calls
          0  db block gets
        922  consistent gets
          4  physical reads
          0  redo size
      39151  bytes sent via SQL*Net to client
       1045  bytes received via SQL*Net from client
         62  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        905  rows processedFollowing is the view it's accessing
CREATE OR REPLACE VIEW CM_PER_PHONE_VW
AS
SELECT
  per_id
  , MAX(DECODE(TRIM(phone_type_cd), 'MOB', phone)) AS MOB
  , MAX(DECODE(TRIM(phone_type_cd), 'HOME', phone)) AS HOME
  , MAX(DECODE(TRIM(phone_type_cd), 'BUSN', TRIM(phone) || ' ' || TRIM(extension))) AS BUSN
  , MAX(DECODE(TRIM(phone_type_cd), 'FAX', phone)) AS FAX
  , MAX(DECODE(TRIM(phone_type_cd), 'INT', phone)) AS INT
FROM
  ci_per_phone
GROUP BY
  per_idI have following indexes on table ci_per_phone
INDEX_NAME                     COLUMN_NAME                    COLUMN_POSITION
XM172P0                        PER_ID                                       1
XM172P0                        SEQ_NUM                                      2
XM172S1                        PHONE                                        1
CM172C0                        PER_ID                                       1I tried creating indexes on PER_ID and PHONE_TYPE_CD but the consistent gets reduces to 920 instead of 922.
Just for curiosity, how can I reduce this?
secondly, is there any explanation on 'OPERATION' break of the plan, e.g. TABLE ACCESS BY INDEX ROWID ?
Please advice.
Luckys.

Further I'm having problem with another query which is a view
CREATE OR REPLACE VIEW CM_PER_CHAR_VW
AS
SELECT
/*+ full (a) */
  a.acct_id
  , MAX(DECODE(a.char_type_cd, 'ACCTYPE', a.char_val)) acct_type
  , MAX(DECODE(a.char_type_cd, 'PRVBLCYC', a.adhoc_char_val)) prev_bill_cyc
FROM
  ci_acct_char a
WHERE
  a.effdt =
    (SELECT
      MAX(a1.effdt)
    FROM
      ci_acct_char a1
    WHERE a1.acct_id = a.acct_id
    AND a1.char_type_cd = a.char_type_cd)
GROUP BY
  a.acct_idI'm not able to reduce the consistent gets and even the filter appears.
I've analyzed the table as well as the index on the table.
cisadm@CCBDEV> select * from cm_acct_char_vw;
2649 rows selected.
Execution Plan
Plan hash value: 132362271
| Id  | Operation              | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT       |              |    27 |  4536 |    14   (8)| 00:00:01 |
|   1 |  HASH GROUP BY         |              |    27 |  4536 |    14   (8)| 00:00:01 |
|   2 |   VIEW                 |              |    27 |  4536 |    14   (8)| 00:00:01 |
|*  3 |    FILTER              |              |       |       |            |          |
|   4 |     HASH GROUP BY      |              |    27 |  2916 |    14   (8)| 00:00:01 |
|   5 |      NESTED LOOPS      |              |  2686 |   283K|    13   (0)| 00:00:01 |
|   6 |       TABLE ACCESS FULL| CI_ACCT_CHAR |  2686 |   157K|    12   (0)| 00:00:01 |
|*  7 |       INDEX RANGE SCAN | XM064P0      |     1 |    48 |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   3 - filter("A"."EFFDT"=MAX("A1"."EFFDT"))
   7 - access("A1"."ACCT_ID"="A"."ACCT_ID" AND
              "A1"."CHAR_TYPE_CD"="A"."CHAR_TYPE_CD")
Statistics
          0  recursive calls
          0  db block gets
       2754  consistent gets
          0  physical reads
          0  redo size
      76517  bytes sent via SQL*Net to client
       2321  bytes received via SQL*Net from client
        178  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       2649  rows processedhere's the tkprof
select *
from
cm_acct_char_vw
call     count       cpu    elapsed       disk      query    current        rows
Parse        2      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      178      0.07       0.05          0       2754          0        2649
total      181      0.07       0.05          0       2754          0        2649
Misses in library cache during parse: 1
Optimizer mode: CHOOSE
Parsing user id: 63  (CISADM)
Rows     Execution Plan
      0  SELECT STATEMENT   MODE: CHOOSE
      0   HASH (GROUP BY)
      0    VIEW
      0     FILTER
      0      HASH (GROUP BY)
      0       NESTED LOOPS
      0        TABLE ACCESS   MODE: ANALYZED (FULL) OF 'CI_ACCT_CHAR'
                   (TABLE)
      0        INDEX   MODE: ANALYZED (RANGE SCAN) OF 'XM064P0'
                   (INDEX (UNIQUE))
Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     179        0.00          0.00
  SQL*Net message from client                   179        0.00          0.08
********************************************************************************I've an similar query for another table, where there are 1110 rows, but in the explain, no filter appears in the predicate
Predicate Information (identified by operation id):
   2 - access("P"."EFFDT"="VW_COL_1" AND "PER_ID"="P"."PER_ID" AND
              "CHAR_TYPE_CD"="P"."CHAR_TYPE_CD")Both the queries have somewhat similar views.
I've got 2 questions,
Is there a way I can reduce the consistent gets( I've tried with/without HINTS),
secondly whats the predicate access shows as 'VW_COL_1'
please advice.

Similar Messages

  • Consistant gets query

    Hi all,
    I have a query about consistant gets. When we see statistics or the output when autotrace is on, we see a value "consistant gets".
    According to docs, its the number of blocks read in "consistant read" mode. I am confused here.
    Say, a query began to run. The process looked through the database buffers for data, for a SCN number. Lets say, the result of my query was in 1000 blocks. Out of which 500 were taken by rolling back some data, as it was mofified by another process while my query was executing.
    Now, should we say Buffer Gets=500 and Consistant gets=500
    OR
    all 1000 blocks were consistant gets.
    If I am getting too many consistant gets, what should I do ? increase DB_BLOCK_BUFFERS ( DB_CACHE_SIZE in 9i ) ? or what ?
    Please explain.
    Regards

    For any SELECT query, all reads will be done as consistent gets. A consistent get means that Oracle is reading the blocks (whether out of cache or from disk) at a particular point in time. It may or may not need to look into rollback segments to so this. In a query, the read is consistent as at the time your query started
    A block get is a read of the current value of a block. Typically, when Oracle reads the data dictionary (not you querying, but Oracle reading it as recursive sql) it reads the current values. Also, when you do an update, Oracle will use consistent gets to find the candidate rows, then a block get just before updating.
    In your example, all 1000 blocks would be consistent gets, although there may be a few block gets as well, particularly if Oracle needed to do physical reads.
    If you are getting too many consistent gets (actually logical I/O's) then you need to re-write the query to be more efficient. Although, the question of what is "too many" is often very difficult to answer.
    HTH
    John

  • Consistent gets and db block gets

    Hi...
    I wanted to know the difference between consistent gets and db block gets in v$sess_io.I have read that consistent gets is the blocks in consistent mode..so here what does consistent mode means????
    Thanks in Advance,
    Anand

    Here's the complete text of the answer I originally wrote nearly 5 years ago on the Oracle-L mailing list:
    A 'db block get' is a current mode get. That is, it's the most up-to-date copy of the data in that block, as it is right now, or currently. There can only be one current copy of a block in the buffer cache at any time. Db block gets generally are used when DML changes data in the database. In that case, row-level locks are implicitly taken on the updated rows. There is also at least one well-known case where a select statement does a db block get, and does not take a lock. That is, when it does a full table scan or fast full index scan, Oracle will read the segment header in current mode (multiple times, the number varies based on Oracle version).
    A 'consistent get' is when Oracle gets the data in a block which is consistent with a given point in time, or SCN. The consistent get is at the heart of Oracle's read consistency mechanism. When blocks are fetched in order to satisfy a query result set, they are fetched in consistent mode. If no block in the buffer cache is consistent to the correct point in time, Oracle will (attempt to) reconstruct that block using the information in the rollback segments. If it fails to do so, that's when a query errors out with the much dreaded, much feared, and much misunderstood ORA-1555 "snapshot too old".
    As to latching, and how it relates, well, consider that the block buffers are in the SGA, which is shared memory. To avoid corruption, latches are used to serialize access to many linked lists and data structures that point to the buffers as well as the buffers themselves. It is safe to say that each consistent get introduces serialization to the system, and by tuning SQL to use more efficient access paths, you can get the same answer to the same query but do less consistent gets. This not only consumes less CPU, it also can significantly reduce latching which reduces serialization and makes your system more scalable.
    Well, that turned out longer than I planned. If you're still reading, I hope it helped!
    Hope that helps,
    -Mark
    PS The original question asked about latching as well, which explains the reason for the third paragraph.
    Edited by: mbobak on Sep 2, 2008 11:07 PM

  • Consistent gets are reduced by 50% but the query taking more elapsed time.

    Hi All,
    While tuning a application my consistent gets are reduced by 50% but the query is still taking the same time.
    In a Warehouse env data is coming from With clause that is having some 40000 rows .Then these 40K rows are joined to a table that is having 2 Billion records having indexes on primary key and date column(bitmap)indexes .
    It is using Hash Joining method.

    Try forcing a hash join, if possible:
    http://dba-oracle.com/tips_oracle_hash_joins.htm
    Can you post the plans?
    http://www.dba-oracle.com/plsql/t_plsql_plans.htm

  • Consistent gets are reduced but elapsed time is increased.

    Hi All,
    While tuning a application my consistent gets are reduced by 50% but the query is still taking the same time.
    In a Warehouse env data is coming from With clause that is having some 40000 rows .Then these 40K rows are joined to a table that is having 2 Billion records having indexes on primary key and date column(bitmap)indexes .

    This forum is for issues with the SQL Developer tool. You'd get more response in the General Database forum.
    Have fun,
    K.

  • Consistent gets are reduced by 50% but the query is still taking the same t

    Hi ,
    I am tuning a query in DWH env using a WITH clause .Doing that my consistent gets are reduced by 50% but the elapsed time in increased.
    In that one 40000 rows are coming from WITH clause and joined with a table having 250000000 rows joined through Hash join.
    can anybody help me out in this issue.
    Thanx
    Nitin

    NitinMishra wrote:
    Hi ,
    I am tuning a query in DWH env using a WITH clause .Doing that my consistent gets are reduced by 50% but the elapsed time in increased.Unusual! Normally time goes, down when system resources do - but not always as you are seeing :(. Last time I saw something like this the reads had gone down but the CPU usage had gone up. You can get CPU usage from V$SQL.
    Can you post the query, the execution plan, and statistics - both before and after the tuning?

  • Which consistent get for which block

    Hello Experts,
    I have conducted an experiment at SQL*PLUS. I created a small table with 100 rows and then create an ununique index on the id column.
    SQL> alter system flush shared_pool;
    Sistem dei■tirildi.
    SQL> create table small as
    2 select rownum id, 'BOWIE' name from dual connect by level <= 100;
    SQL> create index small_id_i on small(id);
    SQL> alter session set tracefile_identifier = '100114_deneme2';
    Oturum dei■tirildi.
    SQL> exec dbms_monitor.session_trace_enable(waits => true);
    PL/SQL yordam² ba■ar²yla tamamland².
    SQL> select * from small where id = 44;
            ID NAME
            44 BOWIE
    SQL> exec dbms_monitor.session_trace_disable;
    PL/SQL yordam² ba■ar²yla tamamland².
    After executed the above, I looked the trace file. The following excerpt was taken from end of the trace file.
    =====================
    PARSING IN CURSOR #4 len=210 dep=1 uid=0 oct=3 lid=0 tim=7391216619 hv=864012087 ad='7ff5f8385a8' sqlid='96g93hntrzjtr'
    select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size, minimum, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln from hist_head$ where obj#=:1 and intcol#=:2
    END OF STMT
    EXEC #4:c=0,e=19,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=3,plh=2239883476,tim=7391216618
    FETCH #4:c=0,e=10,p=0,cr=2,cu=0,mis=0,r=0,dep=1,og=3,plh=2239883476,tim=7391216713
    CLOSE #4:c=0,e=2,dep=1,type=3,tim=7391216749
    =====================
    PARSING IN CURSOR #5 len=33 dep=0 uid=85 oct=3 lid=85 tim=7391217024 hv=1889534919 ad='7ff5f503f40' sqlid='c97q0gdsa00y7'
    select * from small where id = 44
    END OF STMT
    PARSE #5:c=46800,e=121273,p=0,cr=52,cu=0,mis=1,r=0,dep=0,og=1,plh=1841720936,tim=7391217023
    EXEC #5:c=0,e=17,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=1841720936,tim=7391217119
    WAIT #5: nam='SQL*Net message to client' ela= 1 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=7391217185
    FETCH #5:c=0,e=21,p=0,cr=2,cu=0,mis=0,r=1,dep=0,og=1,plh=1841720936,tim=7391217243
    WAIT #5: nam='SQL*Net message from client' ela= 304 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=7391217590
    FETCH #5:c=0,e=13,p=0,cr=1,cu=0,mis=0,r=0,dep=0,og=1,plh=1841720936,tim=7391217673
    STAT #5 id=1 cnt=1 pid=0 pos=1 obj=76014 op='TABLE ACCESS BY INDEX ROWID SMALL (cr=3 pr=0 pw=0 time=0 us cost=2 size=20 card=1)'
    STAT #5 id=2 cnt=1 pid=1 pos=1 obj=76015 op='INDEX RANGE SCAN SMALL_ID_I (cr=2 pr=0 pw=0 time=0 us cost=1 size=0 card=1)'
    WAIT #5: nam='SQL*Net message to client' ela= 1 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=7391217792
    *** 2014-01-10 15:10:36.712
    WAIT #5: nam='SQL*Net message from client' ela= 23061079 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=7414278895
    CLOSE #5:c=0,e=27,dep=0,type=0,tim=7414279115
    =====================
    PARSING IN CURSOR #1 len=48 dep=0 uid=85 oct=47 lid=85 tim=7414281226 hv=3585424577 ad='7ff5f6ea810' sqlid='fypj2tgavag61'
    BEGIN dbms_monitor.session_trace_disable; END;
    END OF STMT
    PARSE #1:c=15600,e=2045,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,plh=0,tim=7414281224
    EXEC #1:c=0,e=1052,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,plh=0,tim=7414282442
    My question is; Although this is very small table, I created an index. As you can see there are 3 consistent gets arise (cr=3). There is no doubt that the first consistent get happen on leaf block and the other on the table block. However, Does the third consistent get happen on which block?
    In my opinion, The last consistent get should be on table block. Becacuse, according to the following thread  (https://community.oracle.com/message/10711767). As far as I know from Solomon, there is fetch and there is prefetch. SQL*PLUS is written in OCI and in OCI prefetch defaults to 1. So, if you issue a query on SQL*PLUS and if this query returns one or more rows the first fetch and the second fetch should be on the same table block.
    Also, can't we say that the last cr happen on table block by looking explain plan? Because, as it can be seen, cr was icreamented when table access by index rowid small line.
    STAT #5 id=1 cnt=1 pid=0 pos=1 obj=76014 op='TABLE ACCESS BY INDEX ROWID SMALL (cr=3 pr=0 pw=0 time=0 us cost=2 size=20 card=1)'
    STAT #5 id=2 cnt=1 pid=1 pos=1 obj=76015 op='INDEX RANGE SCAN SMALL_ID_I (cr=2 pr=0 pw=0 time=0 us cost=1 size=0 card=1)'
    My second question, What can we do in order to understand which consistent get happen on which block (file# block# etc.)? Can't we understand by looking the trace file?
    My third question is, before issue the select query on table. I flushed the shared pool. Does it make the parse 52 cr (Because of recursive calls)???
    PARSE #5:c=46800,e=121273,p=0,cr=52,cu=0,mis=1,r=0,dep=0,og=1,plh=1841720936,tim=7391217023
    I also trace 10200 event, if you want I also can show 10200 trace file. I didn't show it because I don't know how to read 10200 trace event.
    Thanks in advance.

    For example following 10200 trace event arised by select * from small where id = 42;
    *** 2014-01-10 14:56:58.492
    *** SESSION ID:(135.468) 2014-01-10 14:56:58.492
    *** CLIENT ID:() 2014-01-10 14:56:58.492
    *** SERVICE NAME:(SYS$USERS) 2014-01-10 14:56:58.492
    *** MODULE NAME:(SQL*Plus) 2014-01-10 14:56:58.492
    *** ACTION NAME:() 2014-01-10 14:56:58.492
    ktrget2(): started for block  <0x0004 : 0x010006bb> objd: 0x000128ee
    env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 97sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexf(): returning 9 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgcm(): completed for block  <0x0004 : 0x010006bb> objd: 0x000128ee
    ktrget2(): completed for  block <0x0004 : 0x010006bb> objd: 0x000128ee
    ktrgtc2(): started for block <0x0004 : 0x010006c3> objd: 0x000128ef
      env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 97sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexc(): returning 8 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgtc2(): completed for block <0x0004 : 0x010006c3> objd: 0x000128ef
    ktrgtc2(): started for block <0x0000 : 0x00400b49> objd: 0x000001aa
      env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 96sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexc(): returning 2 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgtc2(): completed for block <0x0000 : 0x00400b49> objd: 0x000001aa
    ktrget2(): started for block  <0x0000 : 0x00415c82> objd: 0x000001aa
    env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 96sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexf(): returning 9 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgcm(): completed for block  <0x0000 : 0x00415c82> objd: 0x000001aa
    ktrget2(): completed for  block <0x0000 : 0x00415c82> objd: 0x000001aa
    ktrgtc2(): started for block <0x0004 : 0x010006c3> objd: 0x000128ef
      env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 97sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexc(): returning 8 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgtc2(): completed for block <0x0004 : 0x010006c3> objd: 0x000128ef
    ktrget2(): started for block  <0x0004 : 0x010006bb> objd: 0x000128ee
    env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 97sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexf(): returning 9 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgcm(): completed for block  <0x0004 : 0x010006bb> objd: 0x000128ee
    ktrget2(): completed for  block <0x0004 : 0x010006bb> objd: 0x000128ee
    ktrget2(): started for block  <0x0004 : 0x010006c3> objd: 0x000128ef
    env: (scn: 0x0000.004d5549  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 96sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.004d550c)
    ktrexf(): returning 9 on:  0000000021DD1524  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
    ktrgcm(): completed for block  <0x0004 : 0x010006c3> objd: 0x000128ef
    ktrget2(): completed for  block <0x0004 : 0x010006c3> objd: 0x000128ef

  • Consistent gets examination

    " You have 3,847.1 consistent gets examination per second. "Consistent gets - examination" is different than regular consistent gets. It is used to read undo blocks for consistent read purposes, but also for the first part of an index read and hash cluster I/O. To reduce logical I/O, you may consider moving your indexes to a large blocksize tablespace. Because index splitting and spawning are controlled at the block level, a larger blocksize will result in a flatter index tree structure.
    Can you explain the above and help me understand it?
    What is index split and spawning? why does it happen and what is the fix?
    Which indexes are affected? Is there a query to find out? What is an optimal block size to use for these affected index table spaces?

    I'd strongly suggest you start reading the Oracle DBA manual to get a bit more basics behind you before you get into the advanced tuning stuff. It's at http://docs.oracle.com

  • Consistent gets and physical reads

    Hi all,
    I am tuning a DM SQL query, by comparing execution plans with STAR TRANSFORMATION enabled or disabled. I got the following results:
    STAR TRANSFORMATION ON
    74889 consistent gets
    254365 physical reads
    STAR TRANSFORMATION OFF
    1945892 consistent gets
    168028 physical reads
    I thought a physical read would be counted as a logical read as well, because the data block would be read from disk (1 physical IO), placed in the buffer cache and then read from there (1 more logical IO or consistent get).
    So, one physical IO does not cause a logical IO?
    Thanks!
    Edited by: user10634835 on 12-Jul-2011 08:40

    But shouldn't consistent gets be >= physical reads (Since, as per my understanding, 1 PIO causes at least 1 LIO)? In this case it is not.
    74889 consistent gets
    254365 physical readsJust clarifying for my knowledge.
    regards

  • Query 1 shows less consistent gets but more cost than Query 2..

    Hi ,
    SQL> select dname from scott.dept where deptno not in (select deptno from scott.emp)
    Ðñüãñáììá åêôÝëåóçò
    Plan hash value: 3547749009
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    1 |    22 | 4 (0)| 00:00:01 |
    |*  1 |  FILTER            |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| DEPT |     4 |    88 | 2 (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |    11 |   143 |  2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "SCOTT"."EMP" "EMP"
                  WHERE LNNVL("DEPTNO"<>:B1)))
       3 - filter(LNNVL("DEPTNO"<>:B1))
    Note
       - dynamic sampling used for this statement
    ÓôáôéóôéêÜ
              0  recursive calls
              0  db block gets
             15 consistent gets
              0  physical reads
              0  redo size
            416  bytes sent via SQL*Net to client
            384  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL>
    SQL> select dname from scott.dept,scott.emp where dept.deptno=emp.deptno(+)
      2    and emp.rowid is null;
    Ðñüãñáììá åêôÝëåóçò
    Plan hash value: 2146709594
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |   12 |   564 | 5 (20)| 00:00:01 |
    |*  1 |  FILTER             |      |       |       |            |          |
    |*  2 |   HASH JOIN OUTER   |      |    12 |   564 | 5 (20)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| DEPT |     4 |    88 | 2 (0)| 00:00:01 |
    |   4 |    TABLE ACCESS FULL| EMP  |    12 |   300 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("EMP".ROWID IS NULL)
       2 - access("DEPT"."DEPTNO"="EMP"."DEPTNO"(+))
    Note
       - dynamic sampling used for this statement
    ÓôáôéóôéêÜ
              0  recursive calls
              0  db block gets
              6 consistent gets
              0  physical reads
              0  redo size
            416  bytes sent via SQL*Net to client
            384  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processedI have two questions:
    1) which one is preferable.... the first which is less costy to the system or the second which causes less consistent gets to the system and so is considered to be more scalable..????
    2)Whereas the number of rows returned by both queries is 1.. why the is difference in the underlined values in the two queries (values 1 and 12 respectively)?
    I use Oracle10g v.2
    Thanks.. a lot
    Sim

    The less logical I/O's the better.
    So always do it like your query 2 (btw. your title is the wrong way)
    Your example is probably flawed. If I try it in SQL*Plus I get correct results:
    SQL> get t
      1* select dname from dept where deptno not in (select deptno from emp)
    SQL> /
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=3 Bytes=39)
       1    0   FILTER
       2    1     TABLE ACCESS (FULL) OF 'DEPT' (TABLE) (Cost=2 Card=4 Bytes=52)
       3    1     TABLE ACCESS (FULL) OF 'EMP' (TABLE) (Cost=2 Card=1 Bytes=3)
    Statistics
              0  recursive calls
              0  db block gets
             15  consistent gets
              0  physical reads
              0  redo size
            537  bytes sent via SQL*Net to client
            660  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> get tt
      1  select dname from dept,emp where dept.deptno=emp.deptno(+)
      2* and emp.rowid is null
    SQL> /
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=5 Card=14 Bytes=322)
       1    0   FILTER
       2    1     HASH JOIN (OUTER) (Cost=5 Card=14 Bytes=322)
       3    2       TABLE ACCESS (FULL) OF 'DEPT' (TABLE) (Cost=2 Card=4 Bytes=52)
       4    2       TABLE ACCESS (FULL) OF 'EMP' (TABLE) (Cost=2 Card=14 Bytes=140)
    Statistics
              0  recursive calls
              0  db block gets
              6  consistent gets
              0  physical reads
              0  redo size
            537  bytes sent via SQL*Net to client
            660  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> I'm wondering for instance why you have there 11 rows in emp for query 1 (should be only 1 row) and why you have only 12 rows in query 2 (should be 14 rows)

  • Consistent Gets statistic

    I would like to get a better understanding of what exactly this statistic means. Oracle documentation states:
    Consistent Gets is the number of times a consistent read was requested for a block.
    Is the data included in Consistent Gets coming from a Rollback Segment of from a DB Cache?
    In the datawarehousing environment with very heavy reporting and ETL running at the same time, when Consistent Gets statistic is 5 times higher than Physical Reads, is that a reason for concern?

    In the datawarehousing environment with very heavy reporting and ETL running at the same time, when Consistent Gets statistic is 5 times higher than Physical Reads, is that a reason for concern? <<It doesn't sound relevant -- if your reporting is using parallel query then it is bypassing the buffer cache, hence a logical i/o against the table being parallel-scanned is going to be a physical i/o also. So, much would depend on how much use you are making of parallel query.
    The parallel query LIO/PIO effect is easy to demonstrate by querying a chunk of data twice with a noparallel hint and twice with a parallel hint, and having autotrace turned on. you'll see the PIO's drop down on the second execution of the noparallel query, but on the parallel query they'll remain pretty much the same on the second execution.

  • High Consistent Gets and memory settings

    What is actually high consistent gets?
    I get High Consistent Gets for certain sessions. Following are some of my parameter settings.
    db_16k_cache_size = 0
    db_2k_cache_size = 0
    db_32k_cache_size = 0
    db_4k_cache_size = 0
    db_8k_cache_size = 0
    db_block_size = 8192
    sga_max_size = 7632M
    sga_target = 7632M
    shared_pool_reserved_size = 119957094
    shared_pool_size = 48M
    pga_aggregate_target = 1500M
    Will setting AMM by configuring following parameter help Oracle to manage the memory in terms of workload and reduce CONSISTENT GETS?
    Or do I need to manually configure parameter such as "db_8k_cache_size".?
    memory_max_target = my SGA+PGA: 9.5G
    memory_target = my SGA+PGA: 9.5G
    sga_target = 0
    pga_agreegate_target =0
    Regards, Lily

    Lily wrote:
    What is actually high consistent gets?These are the logical IO's . If the logical IOs are high, it may mean that you have selected a lot of data which is now supposed to be given back to you. The high Logical IOs is not something that you should try to minimize using a high amount of memory since its already cached data. That sort of workaround works or would work if the physical IOs are high. If the session is doing more logical IO's check the query and the selectivity of the data and see if you can limit it further.
    I get High Consistent Gets for certain sessions. Following are some of my parameter settings.
    db_16k_cache_size = 0
    db_2k_cache_size = 0
    db_32k_cache_size = 0
    db_4k_cache_size = 0
    db_8k_cache_size = 0
    db_block_size = 8192
    sga_max_size = 7632M
    sga_target = 7632M
    shared_pool_reserved_size = 119957094
    shared_pool_size = 48M
    pga_aggregate_target = 1500M
    Will setting AMM by configuring following parameter help Oracle to manage the memory in terms of workload and reduce CONSISTENT GETS?
    Or do I need to manually configure parameter such as "db_8k_cache_size".?
    memory_max_target = my SGA+PGA: 9.5G
    memory_target = my SGA+PGA: 9.5G
    sga_target = 0
    pga_agreegate_target =0
    As I said, instance tuning is not something that you should aim for .
    Aman....

  • Consistent gets/physical reads issue

    Dear all,
    There are not any of DML on table tb_hxl_user.
    First Select:
    SQL> select count(1) from tb_hxl_user;
      COUNT(1)                                                                     
    286435658                                                                     
    Elapsed: 00:04:03.67                                                       
    Statistics
            357  recursive calls                                                   
              0  db block gets                                                     
        2106478  consistent gets                                                   
        2106316  physical reads                                                    
              0  redo size                                                         
            422  bytes sent via SQL*Net to client                                  
            416  bytes received via SQL*Net from client                            
              2  SQL*Net roundtrips to/from client                                 
              6  sorts (memory)                                                    
              0  sorts (disk)                                                      
              1  rows processed                                                     Second Select:
    SQL> select count(1) from tb_hxl_user;
      COUNT(1)                                                                     
    286435658                                                                     
    Elapsed: 00:03:02.29
    Statistics
              0  recursive calls                                                   
              0  db block gets                                                     
        2106395  consistent gets                                                   
        2106273  physical reads                                                    
              0  redo size                                                         
            422  bytes sent via SQL*Net to client                                  
            416  bytes received via SQL*Net from client                            
              2  SQL*Net roundtrips to/from client                                 
              0  sorts (memory)                                                    
              0  sorts (disk)                                                      
              1  rows processed                                                     After the first,I know that all the blocks have been flushed to SGA,
    but the second select,it generated many " 2106395 consistent gets" and " 2106273 physical reads" also,
    why?

    What exactly is consistent gets read below link:
    http://jonathanlewis.wordpress.com/2009/06/12/consistent-gets-2/
    Which is similar to docs clearity and authenticity.
    What exactly is physical read read below link:
    http://download.oracle.com/docs/cd/B16240_01/doc/doc.102/e16282/oracle_database_help/oracle_database_instance_throughput_physreads_ps.html
    Regards
    Girish Sharma

  • Consistent gets

    Hi,
    Working on 12c. Run the following query two times to check the consistent gets
    First time it is 242 and second time it is 15.
    SQL> set autotrace traceonly
    SQL> select * from employees;
    107 rows selected.
    Execution Plan
    Plan hash value: 1445457117
    | Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |           |   107 |  6634 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMPLOYEES |   107 |  6634 |     3   (0)| 00:00:01 |
    Statistics
            125  recursive calls
              0  db block gets
            247  consistent gets
             11  physical reads
              0  redo size
          10499  bytes sent via SQL*Net to client
            621  bytes received via SQL*Net from client
              9  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
            107  rows processed
    SQL>/
    Execution Plan
    Plan hash value: 1445457117
    | Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |           |   107 |  6634 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMPLOYEES |   107 |  6634 |     3   (0)| 00:00:01 |
    Statistics
              0  recursive calls
              0  db block gets
             15  consistent gets
              0  physical reads
              0  redo size
          10499  bytes sent via SQL*Net to client
            621  bytes received via SQL*Net from client
              9  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            107  rows processed
    FYI..
    From dba_tables, block=5 , empty blocks 3 and arraysize =15
    Can you please help me to know that how consistent gets is being calculated?
    Thanks,

    >Can you please help me to know that how consistent gets is being calculated?
    why does it matter?
    how will you act differently after you have the answer/

  • Consistent Gets Doubt

    Hello,
    Consistent Gets

    Aman.... wrote:
    Well, as I said before, there is an overhead that would be always there, ALWAYS, when you would be reading the data from the table and this would be there with per execution! What does this mean that whenever you would read the data of the query, oracle would read the extent map of the table and for this , would incur additional ios and then will start fetching the data of the table. This overhead is going to be there when you have the data or won't have the data in the table. See the below demo and tell me what you have understood, forget your demo for a moment,I understood the point that there will ALWAYS be overhead but I am trying to find out how much of the total work is overhead.
    Not sure what you are trying to show with your demo. It is similar to my test case except with more data spread over multiple blocks (which I want to avoid)
    So here is your demo, executed on my environment
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> drop table t_new purge ;
    Table dropped.
    SQL> create table t_new(a number) ;
    Table created.
    SQL> exec dbms_stats.gather_table_stats(user, 'T_NEW') ;
    SQL> exec hr.show_space('T_NEW','HR') ;
    Unformatted Blocks .....................            0
    FS1 Blocks (0-25)  .....................            0
    FS2 Blocks (25-50) .....................            0
    FS3 Blocks (50-75) .....................            0
    FS4 Blocks (75-100).....................            0
    Full Blocks        .....................            0
    Total Blocks............................            8
    Total Bytes.............................       65,536
    Total MBytes............................            0
    Unused Blocks...........................            5
    Unused Bytes............................       40,960
    Last Used Ext FileId....................            6
    Last Used Ext BlockId...................          169
    Last Used Block.........................            3
    PL/SQL procedure successfully completed.
    SQL> set autotrace traceonly statistics
    SQL> select * from t_new ;
    no rows selected
    Statistics
              1  recursive calls
              0  db block gets
              3  consistent gets
              0  physical reads
              0  redo size
            270  bytes sent via SQL*Net to client
            374  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              0  rows processed
    SQL> /
    no rows selected
    Statistics
              0  recursive calls
              0  db block gets
              3  consistent gets
              0  physical reads
              0  redo size
            270  bytes sent via SQL*Net to client
            374  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              0  rows processed
    SQL> select count(*) from t_new ;
    Statistics
              1  recursive calls
              0  db block gets
              3  consistent gets
              0  physical reads
              0  redo size
            410  bytes sent via SQL*Net to client
            385  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> /
    Statistics
              0  recursive calls
              0  db block gets
              3  consistent gets
              0  physical reads
              0  redo size
            410  bytes sent via SQL*Net to client
            385  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> set autotrace off
    SQL> begin
      2  for i in 1..1000 loop
      3    insert into t_new values (i);
      4  end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> commit ;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(user, 'T_NEW') ;
    PL/SQL procedure successfully completed.
    SQL> exec hr.show_space('T_NEW','HR') ;
    Unformatted Blocks .....................            0
    FS1 Blocks (0-25)  .....................            0
    FS2 Blocks (25-50) .....................            0
    FS3 Blocks (50-75) .....................            0
    FS4 Blocks (75-100).....................            4
    Full Blocks        .....................            1
    Total Blocks............................            8
    Total Bytes.............................       65,536
    Total MBytes............................            0
    Unused Blocks...........................            0
    Unused Bytes............................            0
    Last Used Ext FileId....................            6
    Last Used Ext BlockId...................          169
    Last Used Block.........................            8
    PL/SQL procedure successfully completed.
    SQL> show arrays
    arraysize 100
    SQL> set autotrace traceonly statistics
    SQL> select * from t_new ;
    1000 rows selected.
    Statistics
              0  recursive calls
              0  db block gets
             17  consistent gets
              0  physical reads
              0  redo size
          10495  bytes sent via SQL*Net to client
            484  bytes received via SQL*Net from client
             11  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           1000  rows processed
    SQL> select count(*) from t_new ;
    Statistics
              0  recursive calls
              0  db block gets
              7  consistent gets
              0  physical reads
              0  redo size
            411  bytes sent via SQL*Net to client
            385  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> set autotrace off
    SQL> select blocks,empty_blocks from user_tables where table_name = 'T_NEW' ;
        BLOCKS EMPTY_BLOCKS
             5            0
    SQL> select count(distinct dbms_rowid.rowid_block_number(rowid)) from t_new ;
    COUNT(DISTINCTDBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID))
                                                      2

Maybe you are looking for

  • Multiple receivers for same message

    Hello Everyone, My requirement is where customer is sending an XML message and this gets converted into IDOC. This XML message has one node which if it has value as X and Y , then it should go to one ERP system. And if this tag is empty or other than

  • HP Photosmart 7450 printer media cards

    The manual for this printer says I can use any standard media card. I have a XD picture card which is supported but what does HP mean by STANDARD. They don't specify what memory capacity is standard for any of the supported media cards. I'm trying to

  • Update 4.3.3 crashed iPad 2

    YEAH THANKS FOR NOTHING APPLE! Ipad 4.3.3 failed on my iPad 2... I have lost everything. IN AN ENDLESS LOOPS OF trying to restore... BE WARNED this update is flakey! Before anyone else wants to write to tell me that there is nothing wrong with it, pl

  • 3 new Cisco Aironet 1600

    Hello I have  3 new Cisco AIR-SAP1602I-E-K9 for a large 2 floor halls. Max Users: 50. What could be the best practice  tools to calculate the  signal coverage + quality + speed when installing the access points through the halls ? Thanks for the answ

  • How do I assign multiple midi in/out ports???

    Help...I have x2 midi keyboards and want to send midi data from each one to x2 separate devices/software instruments, ie Stylus RMX & Absynth thru separate midi in ports. I have a Tascam FW1884 which has x4 midi in/out ports. How do I do this? I've t