DBAsupport.com Forums - Powered by vBulletin
Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: select count(*) takes 2 hours

  1. #1
    Join Date
    Mar 2001
    Location
    New York , New York
    Posts
    577
    Hi,

    It takes around 2 hours to do a select count(*) om a table having 90000 records.

    Why???

    Is it because of the HWM.
    How can i reset it if thats the case
    Ronnie
    ronnie_yours@yahoo.com

    You can if you think you can.

  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    Does this table has primary key?
    If does then:

    select count(pk_field) om from ur_table;

    dont forget analyze this table periodicaly.

  3. #3
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Yes, Check the HWM of the table.

  4. #4
    Join Date
    Jul 2000
    Posts
    521
    HWM need not be the only reason.
    If you really wish to see the effect of HWM, calsulate an 'estimated' size of this table and compare it with its actual size. If the difference is too much, then HWM is the reason.

    Otherwise, there can be so many other reasons.....your server power, load on the server/database,...
    svk

  5. #5
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    It could also be that you db buffer blocks is way to small, and Oracle is doing a disk sort plus reading from the hard drive. Look at how much memory you are giving Oracle. Your sever should have at least 256 MB RAM if not 512 MB RAM.

    Conerning stats, either you are commited to analyzing tables and keeping the stats current or you should just delete all of the stats and use rule based optimization. You might try setting optimizer_method to rule and restarting the database and see if that helps.

  6. #6
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    well... rule wont help at all since it will force a FTS, if you are in 8i and you analyze your table Oracle will perform INDEX FAST FULL SCAN for a select count(*) which is much much faster

    But anyway, counting 90000 rows takes 2 hours it's too much, even in my PC with an SGA of 40MB that can be done between 10~15 minutes (I am the only user of course)

    To find out HWM without analyzing use unused_space procedure in dbms_space package provided by Oracle

    [Edited by pando on 03-22-2002 at 06:52 PM]

  7. #7
    Join Date
    Mar 2002
    Posts
    171
    You may also try COUNT(ROWID) instead. I am sure there will be significant difference.

  8. #8
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    Originally posted by dbafreak
    You may also try COUNT(ROWID) instead. I am sure there will be significant difference.
    And I am sure that if Jurij notices your statement, you will get an answer to that "significant difference" :-))




    Oracle Certified Master
    Oracle Certified Professional 6i,8i,9i,10g,11g,12c
    email: ocp_9i@yahoo.com

  9. #9
    Join Date
    Mar 2002
    Posts
    171
    Julian, correct me if I am wrong. I believe COUNT(rowid) works very fast compared to COUNT(*). Excuse me if I mentioned anythig wrong.

  10. #10
    Join Date
    Feb 2001
    Posts
    389
    run a trace on it and find out where are the waits.
    select count(pk) should be faster since it gets everything from index.
    select count(*) is equivalent to count(1) where it scans all the rows of the table upto HWM.
    All do sorts , so be sure ur sort area size is good enough.

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