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

Thread: Beneficial? View table of recCounts...

  1. #1
    Join Date
    Jan 2000
    Location
    toronto
    Posts
    3
    Hi Everyone,
    I am considering ways to increase the performance of my application, and currently, because I need to record counts of a few tables in the Oracle db, would anyone think that it's beneficial to create a VIEW table that contains (at least) two fields: (tableName, recCount), containing the tableName, and the recCounts of that specified table?

    Eg) SELECT COUNT(*) FROM EMP; -> 230921 records

    View Table: V_TABLERECS
    TABLENAME
    -------------
    'EMP'

    RECCOUNT
    --------------
    230921

    I hope I was clear in my question...

    Please advise..

    Thanks.

    Frank

  2. #2
    Join Date
    Nov 2000
    Posts
    344
    Hi

    I don't think a view will help much. It still has to execute the query to get the results.

    If the results of count(*) do not have to be 100% accurate 100% of the time, why not analyze your tables (daily, weekly, or whatever interval is needed) and then select the results from ALL_TABLES?

    -John

  3. #3
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Or, if they *have* to be accurate, then how about an actual table that is updated through triggers on the target tables? In other words, if you are interested in the count of Table1, then create a trigger on Table1 for inserts and deletes that modifies the record in your new TableRecordCount table for Table1 by either incrementing or decrementing it by the proper amount. This will, of course, slow the inserts and updates slightly, but you need to weigh that against the cost of calculating the total every time you need it. Of course, you may want to start by checking the plan of your SELECT COUNT statements currently to verify that they are not doing tablescans. Here is a thread that discusses that:

    [url]http://www.dbasupport.com/forums/showthread.php?threadid=6617[/url]

    HTH,

    - Chris

  4. #4
    Why don't you investigate in Materialized Views?
    It could help.
    Ramon Caballero, DBA, rcaballe@yahoo.com

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