Home » RDBMS Server » Performance Tuning » SQL Query: slow response time
|
|
Re: SQL Query: slow response time [message #181334 is a reply to message #181195] |
Sat, 08 July 2006 16:02   |
lamhe2804
Messages: 4 Registered: June 2006 Location: Dallas
|
Junior Member |
|
|
We misunderstood the problem. We have 18mil rows with 0000 status compare to few thousands with 9000 status. This explains why response was slow for 0000 status.
Now we have a different problem.
We optimized indexes and created Bitmap index on date field. We are seeing response in milliseconds for 0000 status if there are records for that date. The query takes forever to return if there is no matching data for a given date.
Explain plan doesn't show any difference.
Thanks,
[Updated on: Sat, 08 July 2006 16:58] Report message to a moderator
|
|
|
|
|
Re: SQL Query: slow response time [message #181348 is a reply to message #181341] |
Sat, 08 July 2006 18:14   |
wagnerch
Messages: 58 Registered: July 2006
|
Member |
|
|
lamhe2804 wrote on Sat, 08 July 2006 18:39 | Will check with my DBA about Histogram. Don't have access.
In test, we have not inserted any transactions for a while. We are testing with static data. In real life, there will be lot of inserts/updates.
We have 18 million records, evenly spread across 60 days (@300k per day).
Query takes same time from Java program/PL SQL Developer/SQL Plus window.
It seems like query scans all transactions when it doesn't find matching data within date range.,
|
Okay, I wouldn't use a bitmap index unless you can serialize DML to the table (using an interface and a single job performs the DML). You will create a whole new (much worse) problem.
Please post the DDL for the table & indexes, the queries, explain plans, and some of the index stats. It may very well be generating full table scans for your date index, and if your type_cde column has a limited # of distinct values / num_rows ratio then without the proper histograms it will full scan as well.
If the table has 18 million rows, and 17.9 million rows have type_cde = '0000' and .1 million rows have the type_cde = '9000', and there is only two distinct values in this column then as far as the optimizer is concerned (without a histogram) you have 9 million with 0000 and 9 million with 9000. So clearly fetching half of the table through a index is likely a bad plan, and I wouldn't use an index and neither would Oracle. Keep in mind the histogram is only going to help those rows with '9000' as a value. It may end up making sense not to index the type_cde column at all, it all depends on how you are querying the data.
Now if you have an index on the date column, then you are doing a range scan and range scans use the clustering factor to determine how "orderly" the data is in the blocks with respect to the index. So it may be useful for you to post the clustering_factor & num_rows (should be 18m) of the table. Date stamps can and will work well, if the table & DML against it is designed properly, or they can fail miserably and become completely unusable indexes because the way the DML is performed.
Post back when you have more information.
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 02 14:12:28 CDT 2025
|