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

Thread: Need to tune the sql query

  1. #1
    Join Date
    Jun 2008
    Posts
    38

    Need to tune the sql query

    i have a history table . i m fetching each date's record count.The below query is taking a longer time

    select trunc(history_date),count(*)
    from history_reads
    group by history_date

    Can anyone tune this query so that it should run faster ??

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    group by trunc(history_date)
    Ales
    The whole difference between a little boy and an adult man is the price of toys

  3. #3
    Join Date
    Nov 2005
    Location
    USA
    Posts
    32
    How big is the table? Parallelizing query with hint /*+ PARALLEL(,) */ (which is not tuning) will help in faster execution. Also consider bitmap/b-tree index on trunc(history_date) depending on application type and how frequent the query is used
  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Follow Ales suggestion then create a non-unique index on trunc(history_date)

    Force your query to scan the index -check execution plan; since you need no data from the table scanning the index would be much faster than scanning the table.
    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.

  5. 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