Home > Ask the Oracle Experts > Oracle Performance Tuning Questions & Answers > Slow query performance for customer with large data volume
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Slow query performance for customer with large data volume

Phillip Bracken EXPERT RESPONSE FROM: Phillip Bracken

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 08 June 2007

I have a critical performance issue due to the large volume of data for a specific customer. We have a table Cust-orders, and a customer XYZ -- the number of orders for XYZ stored in the table is more that 50 lakh. Beside XYZ there are 10,000 customers' orders residing in the table but the number of orders for each of them is not more than 5,000.

The problem is whenever customer XYZ's data is being fetched the query takes about half an hour to execute, whereas it fetches the data in seconds for the rest of the customers. I have analyzed and rebuilt the indexes. I have properly ordered the tables and where conditions in my query based on tuning thumb rules. But still the problem persists.

Is there any way to handle this kind of scenario? How can I enhance the performance of the query so it takes less time while fetching the data for Customer XYZ?


>
EXPERT RESPONSE

You don't really say but I am assuming here that you have an Index on the table's Customer ID.

First of all, are you using the DBMS_STATS package to gather stats on your tables? If not, you should be. The analyze table command does not collect all the columns' histogram statistics. If column statistics are not properly gathered, then a column that is indexed but has a high proportion of rows with a certain value may be using the index to retrieve data for that value, when a table scan or other access path would be more efficient. In Oracle 10g, Oracle has automated the gathering of statistics unless it has been disabled. If not, then use the DBMS_Stats.Gather_Schema_Stats to collect statistics on all your schema's table and indexes. Make sure your method option parameter is set to 'for all columns size auto' so that that Oracle collects histogram statistics on your columns.

If your statistics are good, then start a SQL trace of your session using the following alter session command to start a Level 8 trace so WAIT events are captured.

        
alter session set events '10046 trace name context forever, level 8';

Next, run the query that selects customer XYZ, and other queries that select the other customers. After you have run these queries, then disconnect from the database or turn off the trace, and go to the database's UDUMP directory on the database server. Find the trace file you just created and then use the TKPROF utility with the EXPLAIN option to read that trace file and generate an easier-to-read format. What access path are the queries taking? Are they the same? Also look at the Wait Events for each query to see what the largest waiting event is. Using this information you will be able to determine what access path it is using, and with that and the WAIT events information determine a solution. If all queries are using that same customer ID index, then my first guess would be that the problem is occurring because an index is being used to select your XYZ customer when a table scan or other access method might be more efficient. If so try using a hint in this query to force the optimizer to use a table scan and see if that helps.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Oracle Performance Tuning
Can I use TKPROF in Oracle 10g?
How to improve performance of column update
Select on Oracle table takes hours
Import of database dump takes 13 hours
ORA-03297 when trying to resize tablespace
Improve performance of SQL query
SMON process consuming 100% CPU
Total Oracle CPU time
See tablespace utilization/database size without DBA privileges
Simple SQL query takes longer than usual

Oracle database performance problems and tuning
Oracle 11g data compression
Varchar or number for better performance?
Do statistics on SYS-owned objects hurt performance in 10g?
Inside the Oracle 11g SQL Performance Advisor, part 1
Inside the Oracle 11g SQL Performance Advisor, part 2
Difference between driving table and driver table in Oracle
Best design for E-Business Suite on hard drive
20GB data dictionary causing performance problems
Using the cost-based optimizer to improve Database 10g performance
Online tablespace reorganization in Oracle 9i

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts