DBAsupport.com Forums - Powered by vBulletin
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: index not used for negative numbers

  1. #11
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by mitpat121 View Post
    Hi
    sorry
    correct display is as follows
    select * from employee
    where status = 1;
    30

    select * from employee
    where status = -1;
    521
    Is the table 551 rows in size?

    As a rule of thumbs Oracle optimizer would not use an index when more than 15% of the rows have to be retrieved - it is cheaper in terms of I/O to do a full table scan.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  2. #12
    Join Date
    Jul 2010
    Posts
    8
    Hi all,

    how can i find stale stats on particular table.

  3. #13
    Join Date
    Mar 2006
    Location
    Charlotte, NC
    Posts
    865
    Please make a note that if you are using Oracle 10g or above, Oracle has a inbuilt scheduled maintenance job which collect the stats for the required objects as and when needed.

    However, follow the below steps to check.

    1. count the rows in the table (select count(*) from table)
    2. check last_analyzed_date, num_rows from user_tables. num_rows should match with count(*)

    I am not sure if there are any dictionary views available to find the same.

    Thanks,
    Vijay Tummala

    Try hard to get what you like OR you will be forced to like what you get.

  4. #14
    Join Date
    Apr 2008
    Location
    Bangalore
    Posts
    96
    looks like There are more record with status=-1.So optimizer is using FTS.
    Since no of records with status=1 is less optimizer is using Index scan.

  5. #15
    Join Date
    Jul 2010
    Posts
    8
    hi all,

    I am facing performance issue, fornt end these queries are used, it takes 4-5 minutes to load module application page. erlier it was taking max 30 seconds.

    plz provide some suggetions

    thx

  6. #16
    Join Date
    Apr 2008
    Location
    Bangalore
    Posts
    96
    find if stats for table is stale

    use dba_tab_statistics table

  7. #17
    Join Date
    Mar 2006
    Location
    Charlotte, NC
    Posts
    865
    Thanks for shedding more light Mohith. STALE_STATS column in ALL_TAB_STATISTICS is telling about the stale stats.

    Thanks,
    Vijay Tummala

    Try hard to get what you like OR you will be forced to like what you get.

  8. #18
    Join Date
    Jul 2010
    Posts
    8
    hi all,

    i checked dba_tab_statistics for stale stats
    but STALE_STATS column contain no and null values.
    null value for global temporary table what is it mean and
    one more thing i noticed global temporary table has never been analyzed.

    plz provide suggetions
    thx

  9. #19
    Join Date
    Mar 2006
    Location
    Charlotte, NC
    Posts
    865
    Quote Originally Posted by mitpat121 View Post
    hi all,

    i checked dba_tab_statistics for stale stats
    but STALE_STATS column contain no and null values.
    null value for global temporary table what is it mean and
    one more thing i noticed global temporary table has never been analyzed.

    plz provide suggetions
    thx
    that is quite obvious. They are Global TEMPORARY Tables. Please google it for more information.

    Thanks,
    Last edited by vnktummala; 07-29-2010 at 12:46 AM. Reason: typo
    Vijay Tummala

    Try hard to get what you like OR you will be forced to like what you get.

  10. #20
    Join Date
    Aug 2010
    Posts
    3
    I second Mohit123, the optimizer algorithm would find it easier to use an index on the table to find +1 because they are much lesser in number and probably distributed throughout the table and would not use an index if its -1 because its easier to pick the whole thing into memory and find what is required instead of index scan and iterations.

    If you really want to test out the optimizer working, you should make this a much bigger table in a test environment with similar distribution of data. It is then likely to use an index in both cases.

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