DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Performance in a query

  1. #1
    Join Date
    Jul 2001
    Location
    Milano
    Posts
    22

    Red face Performance in a query

    Hi,
    i have a query where i must to control a column (colA) that can assume two values:

    'Dlsw Peer state : 6 ( 6 : disconnected - 3 : connected )'
    'Dlsw Peer state : 3 ( 6 : disconnected - 3 : connected )'

    The difference between this values is only the 20th character (6 or 3). My question is:
    In this case (the table has approximately 10000 record) for performance is better

    colA = 'Dlsw Peer state : 6 ( 6 : disconnected - 3 : connected )';

    or

    substr(colA, 20, 1) = '6';

    or

    colA like '%: 6 %';

    or i don't know what?

    Thank's in advance,
    MaX

  2. #2
    Join Date
    Nov 2002
    Posts
    39
    Do you have an index for the ColA?
    Sathish

  3. #3
    Join Date
    Sep 2001
    Location
    Düsseldorf, Germany.
    Posts
    588
    As the cardinality is low, I guess a functional bitmap index should help...

    Code:
    SQL>create bitmap index ixfunc on temp (substr(columns,20,1));
    Index Creaded.
    
    SQL>select /*+ INDEX(temp ixfunc) */ * from temp where substr(columns,20,1) = '3';
    
    82355 rows selected.
    
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=172 Card=1057 Bytes=
              75047)
    
       1    0   TABLE ACCESS (BY INDEX ROWID) OF 'temp' (Cost=172 Card=
              1057 Bytes=75047)
    
       2    1     BITMAP CONVERSION (TO ROWIDS)
       3    2       BITMAP INDEX (SINGLE VALUE) OF 'IXFUNC'
    
    Statistics
    ----------------------------------------------------------
              6  recursive calls
              4  db block gets
         148100  consistent gets
              0  physical reads
            592  redo size
        3898031  bytes sent via SQL*Net to client
         609815  bytes received via SQL*Net from client
          10984  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          82355  rows processed
    Without Index..

    Code:
    SQL> select * from temp where columns = 'Dlsw Peer state : 3 ( 6 : disconnected - 3 : connected )';
    
    82355 rows selected.
    
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   TABLE ACCESS (FULL) OF 'temp'
    
    Statistics
    ----------------------------------------------------------
              6  recursive calls
             10  db block gets
           6746  consistent gets
              0  physical reads
            592  redo size
        3934019  bytes sent via SQL*Net to client
         609815  bytes received via SQL*Net from client
          10984  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          82355  rows processed
    Sameer
    Last edited by Sameer; 11-26-2002 at 08:46 AM.

  4. #4
    Join Date
    Jul 2001
    Location
    Milano
    Posts
    22
    Thank you very much!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width