Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    26

    Unanswered: Force query to use index and avoid full table scan

    Hi,

    Is there any way to get rid of the full table scan.

    I plan to reduce the response time of this query.

    Code:
    explain plan for
    select a.id,b.*
    from voice a, cust b
    where a.id = b.id
    and a.update_date >= '1-Oct-2008'

    Code:
    -----------------------------------------------------------------------------------------------------
    | Id  | Operation          | Name                   | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |                        |   384K|    14M|       | 43714   (3)| 00:08:45 |
    |*  1 |  HASH JOIN         |                        |   384K|    14M|  9280K| 43714   (3)| 00:08:45 |
    |*  2 |   TABLE ACCESS FULL| voice                  |   379K|  4822K|       | 33818   (3)| 00:06:46 |
    |   3 |   TABLE ACCESS FULL| cust		    |  2778K|    68M|       |  4360   (3)| 00:00:53 |
    -----------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       1 - access("A"."ID"="B"."ID")
       2 - filter("A"."UPDATE_DATE">=TO_DATE('2008-10-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
    I have anayzed both tables, and it has indexes created on id column.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by ajitpal.s
    and it has indexes created on id column.
    If there is no index on update_date, Oracle will need to do a full table scan on voices in order to satisfy your WHERE clause.

    How many rows will be returned by the condition update_date >= '1-Oct-2008' ?
    If more than approx. 20% of the total rows are returned, a full table scan is more efficient than an index scan.

Posting Permissions

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