Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Analyze Table made performance worse!  -- help!

Posted on 2008-06-16
11
Medium Priority
?
1,926 Views
Last Modified: 2013-12-19
I ave a relatively large database that had some minor performance issues.  I had been going through and Analyzing tables and computing statistics.  This improved overall efficiency and the number of buffer gets went down dramatically.


That is, until I analyzed a table that was really out of wack.  The table stats claimed to have 400,000 rows, but a select count(*) showed about a million.  So I analyzed the table and computed statistics.  

When I did that, a query that was only using about 30 buffer gets per transaction now uses over 1,000 buffer gets for the same transaction.

The explain plan shows that the index is no longer being used.  Instead it is doing a full table scan.

What's up with that?  How do I fix it?
0
Comment
Question by:_TAD_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 21795666
how did you analyze?
analyze or dbms_stats?

did you analyze the indexes with the table?
Did you gather histograms?  (should you have? usually no, but sometimes yes you must)
is the table partitioned?  did you gather partition level statistics?


what is the query?
and what are the original and new plans?
0
 
LVL 22

Author Comment

by:_TAD_
ID: 21795873
I ran the following SQL:

Analyze Table <TableName> Compute Statistics;

The last analyzed data time stamp on the idexes match the date-time stamp of the table

no histograms were gathered

The table is not partitioned.

Further, overall query performance against this table has improved tremendously when using other indexes.  The problem is that this one particular index is performing much, much worse -- and the query is run several hundred times a day.
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 21796182

As sdstuber said, you need to analyze the indexes also.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Author Comment

by:_TAD_
ID: 21796406
indexes analyzed.  No change
0
 
LVL 18

Expert Comment

by:rbrooker
ID: 21796685
do not use analyse, it is being deprecated.

what i use is : dbms_stats.gather_table_stats( 'owner', 'table_name', block_sample => true, cascade => true, estimate_percent => 10, method_opt => 'FOR ALL COLUMNS SIZE AUTO' );

try that and see what happens.
0
 
LVL 22

Author Comment

by:_TAD_
ID: 21797226
While I understand that Analyze is, in some circumstances, not as efficient as dbms_stats.  I have not heard that it is being depricated.  It is my understanding that some statistics like high water mark cannot be gotten through dbms_stats, but instead must use analyze.

That being said, I did a full compute, not an estimation.  the dms_stats must be a really awesome tool to produce more accurate statistics with a 10% estimation than a full analysis of 100% of the data.
0
 
LVL 18

Accepted Solution

by:
rbrooker earned 500 total points
ID: 21797347
you can use whatever estimate percent you choose, if you want 100%, then use 100%.  thats not the point.

read this article, long but good.

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4347359891525
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 500 total points
ID: 21797438
what is the query along with the old and new execution plans?

also, what about histograms?  you said you did not gather them,  should you have?
Were they there previously?
0
 
LVL 2

Expert Comment

by:vorb1s
ID: 21824190
Hi,
  fastest solution to try - delete statistics:
analyze table TABLE_NAME delete statistics;

painful, but right solution (in 9i only):
  think about changing the SQL SELECTs, use some indexing hints etc.

you can also try change index cost for session (1-1000 and more :-) like thist (100 - default):
alter session set optimizer_index_cost_adj=100;
Try some lower values and look how the cost in explain plan changes.

Vorbis
0
 
LVL 22

Author Comment

by:_TAD_
ID: 21826667


I wound up rewriting the daemon procedures instead.

The original process....

Count the number of records that... <condition>
If count > 0 Then run process.
   Process... load temp table & cursor use prev. count to itterate through processes one at a time.


New Process....

Select 1 where exists... <condition>

Count the number of records that... <condition>
If count > 0 Then run process.
   Process... load temp table & cursor use prev. count to itterate through processes one at a time.



The original code USED to only use 21 buffer gets right up until the processing.   After the compute of statistics it started to use over 1,000.  Not a big deal normally, but the process runs a few hundred times a day (running the count SQL each and every time).

Now the process does the "where exists" and that uses 11 additional Buffer Gets over the old process (which currently uses 1,000+) -- but only where there is something there to process.  

In a nutshell, I am still taking a big performance hit, but instead of having the highest number of buffer gets in a single day, the new code is somewhere in the middle -- and I can live with that.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 21827148
can you post your before and after code with the before and after execution plans?

we'll all help, but we need something to work from.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question