How important is gathering statistics on SYS objects?

Hi,
How important is gathering statistics on Data dictionary tables and other X$ tables in SYS schema. Is it bad to keep the statistics. Recently our Sr.DBA has deleted all the SYS schema stats telling that it will inversely affect the DB performance. Is it true?
Regards
Satish

Hi Satish,
*10g:*
A new DBA task in Oracle Database 10g is to generate statistics on data dictionary objects which are contained in the SYS schema. The stored procedures dbms_stats.gather_database_stats and dbms_stats.gather_schema_stats can be used to gather the SYS schema stats. Here is an example of using dbms_stats.gather_schema_stats to gather data dictionary statistics:
EXEC dbms_stats.gather_schema_stats(’SYS’);
*9i*
While it is supported in 9.2 to gather statistics on the data dictionary and fixed views, doing so isn't the norm.
There is a bug fixed only in 10gR2 (not expected to be back-ported to 9.2) that caused this error. The fix is – don’t generate statistics against SYS – especially not the Fixed tables.
For this query, let's see if we can get a better plan by removing statistics or by getting better statistics, or if we need to do something else to tune it. Take the SYS statistics as before, but with gather_fixed => false.
I would like for you to test first by deleting the statistics on these two X$ tables and see how the query runs (elapsed time, plan).
delete_table_stats('SYS','X$KQLFXPL');
delete_table_stats('SYS','X$KGLOB');
Then you can take statistics on them using gather_table_stats and check again (elapsed time, plan).
gather_table_stats('SYS','X$KQLFXPL');
gather_table_stats('SYS','X$KGLOB');
The issue with this is that the contents of these fixed views, particularly x$kqlfxpl, can change dramatically. Gathering fixed object statistics may help now and cause problems later as the contents change.
Warning, this is a bit dangerous due to latch contention, see the following note. I've supported a couple of very busy systems that were completely halted for a time due to latch contention on x$kglob due to monitoring queries (particularly on v$open_cursors).
Note.4339128.8 Ext/Pub Bug 4339128 - Heavy latch contention from queries against library cache views.
Hope this answers your question . . .
Donald K. Burleson
Oracle Press author
Author of "Oracle Tuning: The Definitive Reference":
http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm

Similar Messages

  • Oracle 11g upgrade: How to update stale statistics for sys and sysman?

    Hi,
    I am in the process of testing Oracle 11g upgrade from Oracle 10.2.0.3. I have run utlu111i.sql on the 10g database.
    The utility utlu111i.sql reports about the stale statistics for SYS and SYSMAN components.
    I executed dbms_stats.gather_dictionary_stats; dbms_stats.gather_schema_stats('SYS'); and dbms_stats.gather_schema_stats('SYSMAN');
    After that the utlu111i.sql still reports the stale statistics for sys and sysman. Does anyone know how to get rid off this warning successfully?
    Thanks,
    Sreekanth

    Does anyone know how to get rid off this warning successfully?Just ignore the warnings. Check The Utlu111i.Sql Pre-Upgrade Script Reports Stale Sys Statistics - 803774.1 from Metalink.

  • How to on -gathering statistics of how much a VM is actually used?

    I have a SCVMM 2012 SP1 system managing a bunch of 2012 R2 host servers.  What I am looking to do is to gather statistics and create a report that would tell me how often a system is being used. 
    I can figure out how to get uptime, but what I am looking to do is to weed out VMs that are no longer used, or seldom used over the course of a year.  Even getting stats of when a VM was started or stopped would help me with this.

    Jobs can give you start and stop details.  But only those actions that were performed through SCVMM.
    However, SCVMM is really not designed to track this type of audit history - the MSFT story is to use Operations Manager for that.
    Or, you track over time - doing a dump of status to create your desired history then evaluate this history.
    Trust me, you are not the first to ask.  But it is not a core story of SCVMM.  And it has never supported this type of history.
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

  • How to join sys.dm_exec_query_stats to FROM sys.sql_modules as M INNER JOIN sys.objects

    0
    SELECT O.Name as ProcName
    ,M.Definition as CreateScript
    ,O.Create_Date
    ,O.Modify_Date
    FROM sys.sql_modules as M INNER JOIN sys.objects as O
    ON M.object_id = O.object_id
    WHERE O.type = 'P'
    --Procedure
    --WHERE O.type = 'V' View
    --WHERE O.type = 'FN' Function
    How can I join this to sys.dm_exec_query_stats to
    get the execution_count?

    You can join to sys.dm_exec_procedure_stats using object_id for procedures in cache and get execution count
    http://msdn.microsoft.com/en-in/library/cc280701(v=sql.110).aspx
    for ones not in cache you need to use logic like below
    SELECT O.Name as ProcName
    ,M.Definition as CreateScript
    ,O.Create_Date
    ,O.Modify_Date
    ,QS.execution_count
    FROM sys.dm_exec_query_stats AS QS
    CROSS APPLY sys.dm_exec_sql_text(QS.sql_handle) t
    INNER JOIN sys.sql_modules as M
    ON M.object_id = t.objectid
    INNER JOIN sys.objects as O
    ON M.object_id = O.object_id
    WHERE O.type = 'P'
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Non existent table still in sys.objects, how to fix that?

    I have moved a table from one table schema to another one (dbo.MY_TABLE to RAW.MY_TABLE), using ALTER SCHEMA..., the problem is when our ETL is trying to remove all the constraints it finds 2 records (dbo.MY_TABLE), one for the user table and the other
    the PK of that table. The problem is that the sys.objects points to dbo.MY_TABLE which now doesn't exist anymore. How could I update the sys.objects table to correctly reflect that the table has moved table schema?

    Hi,
    sys.objects lists user objects. If
    select * from sys.all_objects where name='MY_TABLE'
    gives you more than 1 table (look at the "type_desc" column), you DO have more than 1 table. One in "dbo" schema and one in the "raw" schema.
    Those 2 tables should have different object_id values. Object_id is unique within a database, and all dependant objects use that object_id to refer to the object. They do not use object_name, schema name, not even schema_id. Just object_id. If you want to
    see all objects, including system objects, query sys.all_objects.
    Regards,
    Vedran

  • How to disable automatic statistics collections on tables

    Hi
    I am using Oracle 10g and we have few tables which are frequently truncated and news rows added to it. Oracle automatically analyzes the table by some means which collects statistics of the table but at the wrong time(when the table is empty). This makes my query to do a full table scan rather using indexes since the statistics was collected when the table was empty.Could any one please let me know how to disable the automatic statistics collection feature of Oracle?
    Cheers
    Anantha PV

    Hi
    I am using Oracle 10g and we have few tables which
    are frequently truncated and news rows added to it.
    Oracle automatically analyzes the table by some means
    which collects statistics of the table but at the
    wrong time(when the table is empty). This makes my
    query to do a full table scan rather using indexes
    since the statistics was collected when the table was
    empty.Could any one please let me know how to disable
    the automatic statistics collection feature of
    Oracle?
    First of all I think it's important that you understand why Oracle collects statistics on these tables: Because it considers the statistics of the object to be missing or stale. So if you just disable the statistics gathering on these tables then you won't have statistics at all or outdated statistics.
    So as said by the previous posts you should gather the statistics manually yourself anyway. If you do so right after loading the data into the truncated table, you don't need to disable the automatic statistics gathering as it only processes objects that are stale or don't have statistics at all.
    If you still think that you need to disable it there are several ways to accomplish it:
    As already mentioned, for particular objects you can lock the statistics using DBMS_STATS.LOCK_TABLE_STATS, or for a complete schema using DBMS_STATS.LOCK_SCHEMA_STATS. Then these statistics won't be touched by the automatic gathering job. You still can gather statistics using the FORCE=>true option of the GATHER__STATS procedures.
    If you want to change the automatic gathering job that it only gathers statistics on objects owned by Oracle (data dictionary, AWR etc.), then you can do so by calling DBMS_STATS.SET_PARAM('AUTOSTATS_TARGET', 'ORACLE'). This is the recommended method.
    If you disable the schedule job as mentioned in the documentation by calling DBMS_SCHEDULER.DISABLE('GATHER_STATS_JOB') then no statistics at all will be gathered automatically, causing your data dictionary statistics to be become stale over time, which could lead to suboptimal performance of queries on the data dictionary.
    All this applies to Oracle 10.2, some of the features mentioned might not be available in Oracle 10.1 (as you haven't mentioned your version of 10g).
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Relation between computing and gathering statistics

    Hi gurus,
    What is the relation between computing and gathering statistics for a database object.Are they mutually dependent or one doesn't have anything to do with the other?How they affect performance of a database??
    plz dont redirect..just bottom lines are expected(be specific)
    Thanks in advance
    anirban

    computing term used to collect 100% statistics along with analyze command.
    gather stats is a new package provided by the oracle, also recommend to use this instead of analyze. You can also take 100% stats, like compute with analyze command, in gather stats pacakge, parameter estimate_percent=>null.
    exec dbms_stats.gather_table_stats('SCHEMA',TABLE',cascade=>true,estimate_percent=>NULL);
    Jaffar

  • How to get the values of the objects inside an object??

    Hi,
    I am trying to write code to display name and memory usage of all session attributes, in a recursive way.
    I suppose reflection is needed here, but I can’t figure out how to get the values of the objects inside an object...
    private void handleIt(String attributeName, Object attributeValue) {
         boolean isPrimitiveOrNull = ((null == attributeValue) ||
              (attributeValue.getClass().isPrimitive()));                                         
         if (isPrimitiveOrNull) {
              sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
         } else {
              sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");               
              Field[] fields = attributeValue.getClass().getDeclaredFields();
              int lim = fields.length;
              String name;
              Object value = null;
              for (int i = 0; i < lim; i++) {
                   name = fields.getName();
                   //LOOK AT THIS LINE: !!!!!!!!!!!!!!!!!!!!!!!!!!!
                   value = fields[i].get(obj); //I don´t know what 'obj' should be??
                   handleIt(name, value);
              sb.append("}");               
    Any suggestions will be greatly appreciated...

    I realized that massive int objects called MAX_VALUE, MIN_VALUE and SIZE where causing the StackOverflow, so I removed them from the analysis.
    This is the resultant code. But I think it isn’t accurate in calculating the real size of objects being got using reflexion.
    Do you or somebody have any more suggestions?
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ObjectOutputStream;
    import java.lang.reflect.Field;
    import java.util.Enumeration;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class SessionMeasurer extends HttpServlet {
         private static final long serialVersionUID = 1470488362727841992L;
         private StringBuilder sb = new StringBuilder();
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              performTask(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              performTask(request, response);
         public void performTask(HttpServletRequest request, HttpServletResponse response) {
              HttpSession     session = request.getSession(false);     
              String attributeName = "";
              Object attributeValue = null;
              for (Enumeration<?> attributeNames = session.getAttributeNames(); attributeNames.hasMoreElements();) {
                   attributeName = (String)attributeNames.nextElement();
                   attributeValue = session.getAttribute(attributeName);
                   handleIt(attributeName, attributeValue);               
              System.out.println(sb.toString());
         private void handleIt(String attributeName, Object attributeValue) {           
              if (attributeValue != null) {          
                   boolean isPrimitive = attributeValue.getClass().isPrimitive();
                   if (isPrimitive) {
                        sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
                   } else {
                        sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");               
                        Field[] fields = attributeValue.getClass().getDeclaredFields();
                        String name;
                        Object value = null;
                        int lim = fields.length;
                        for (int i = 0; i < lim; i++) {
                             name = fields.getName();                                                                                                         
                             if (!name.endsWith("_VALUE") && !name.equals("SIZE") && !name.equals("serialVersionUID")) {
                                  try {
                                       value = fields[i].get(attributeValue);
                                  } catch(Exception e) {
                                       //PENDIENTE: Tratamiento excepción
                                  handleIt(name, value);
                        sb.append("}");               
         private int sizeOf(Object obj) {
              //Valid only for Serializables
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ObjectOutputStream oos = null;     
              byte[] bytes = null;               
              try {          
                   oos = new ObjectOutputStream(baos);
                   oos.writeObject(obj);
                   bytes = baos.toByteArray();
              } catch(Exception e) {               
                   //PENDIENTE: Tratamiento excepción
              } finally {
                   if (oos != null) {
                        try {
                             oos.close();
                        } catch(Exception e) {
                             //PENDIENTE: Tratamiento excepción                         
                   if (baos != null) {
                        try {
                             baos.close();
                        } catch(Exception e) {
                             //PENDIENTE: Tratamiento excepción                         
              int size = -1;
              if (bytes != null) {
                   size = bytes.length;
              return size;          

  • How to find out the Number range object for Incident number

    How to find out the Number range object for Incident number ?
    CCIHT_IAL-IALID
    regards,
    lavanya

    HI, an example.
    data: vl_num type i,
          vl_char(6) type c,
          vl_qty type INRI-QUANTITY,
          vl_rc type INRI-RETURNCODE.
    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        NR_RANGE_NR                   = '01'
        OBJECT                        = 'ZRG0000001'
       QUANTITY                       = '1'
      SUBOBJECT                     = ' '
      TOYEAR                        = '0000'
      IGNORE_BUFFER                 = ' '
    IMPORTING
       NUMBER                        = vl_num
       QUANTITY                      = vl_qty
       RETURNCODE                    = vl_rc
    EXCEPTIONS
       INTERVAL_NOT_FOUND            = 1
       NUMBER_RANGE_NOT_INTERN       = 2
       OBJECT_NOT_FOUND              = 3
       QUANTITY_IS_0                 = 4
       QUANTITY_IS_NOT_1             = 5
       INTERVAL_OVERFLOW             = 6
       BUFFER_OVERFLOW               = 7
       OTHERS                        = 8
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    vl_char = vl_num.
    write vl_char.
    Regard

  • Best practices for gathering statistics in 10g

    I would like to get some opinions on what is considered best practice for gathering statistics in 10g. I know that 10g has auto statistics gathering, but that doesn't seem to be very effective as I see some table stats are way out of date.
    I have recommended that we have at least a weekly job that generates stats for our schema using DBMS_STATS (DBMS_STATS.gather_schema_stats). Is this the right approach to generate object stats for a schema and keep it up to date? Are index stats included in that using CASCADE?
    Is it also necessary to gather system stats? I welcome any thoughts anyone might have. Thanks.

    Hi,
    Is this the right approach to generate object stats for a schema and keep it up to date? The choices of executions plans made by the CBO are only as good as the statistics available to it. The old-fashioned analyze table and dbms_utility methods for generating CBO statistics are obsolete and somewhat dangerous to SQL performance. As we may know, the CBO uses object statistics to choose the best execution plan for all SQL statements.
    I spoke with Andrew Holsworth of Oracle Corp SQL Tuning group, and he says that Oracle recommends taking a single, deep sample and keep it, only re-analyzing when there is a chance that would make a difference in execution plans (not the default 20% re-analyze threshold).
    I have my detailed notes here:
    http://www.dba-oracle.com/art_otn_cbo.htm
    As to system stats, oh yes!
    By measuring the relative costs of sequential vs. scattered I/O, the CBO can make better decisons. Here are the data items collected by dbms_stats.gather_system_stats:
    No Workload (NW) stats:
    CPUSPEEDNW - CPU speed
    IOSEEKTIM - The I/O seek time in milliseconds
    IOTFRSPEED - I/O transfer speed in milliseconds
    I have my notes here:
    http://www.dba-oracle.com/t_dbms_stats_gather_system_stats.htm
    Hope this helps. . . .
    Don Burleson
    Oracle Press author
    Author of “Oracle Tuning: The Definitive Reference”
    http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm

  • How can i find statistics tables in my database?

    code{
    Upgrade Statistics Tables Created by the DBMS_STATS Package
    If you created statistics tables using the DBMS_STATS.CREATE_STAT_TABLE procedure, then upgrade these tables by executing the following procedure:
    EXECUTE DBMS_STATS.UPGRADE_STAT_TABLE('SYS','dictstattab');
    In the example, 'SYS' is the owner of the statistics table and 'dictstattab' is the name of the statistics table. Execute this procedure for each statistics table.
    the above is one of the post upgrade step for 11gR2. How can i find statistics tables in my database?

    You need to read the complete context of this manual upgrade step:
    Step 33
    Upgrade Statistics Tables Created by the DBMS_STATS Package
    If you created statistics tables using the DBMS_STATS.CREATE_STAT_TABLE procedure, then upgrade these tables by executing the following procedure:
    EXECUTE DBMS_STATS.UPGRADE_STAT_TABLE('SYS','dictstattab');
    In the example, 'SYS' is the owner of the statistics table and 'dictstattab' is the name of the statistics table. Execute this procedure for each statistics table.You need to do this step for any statistics table that you created manually with DBMS_STATS.CREATE_STAT_TABLE.
    Marcus

  • Import TermSet CSV using client side object model

    Hello,
    I want to import CSV in TermStore using client side object model. Unfortunately there is no ImportManager here.
    Is there any other way (Other than reading from CSV and adding term one by one to term store)?
    Regards, Nanddeep Nachan

    Hi,
    Here is a tool(server-side) from codeplex for your reference:
    SharePoint 2010 CSV Bulk Taxonomy TermSet Importer/Exporter
    If you want to import termsets  from CSV in Client-Side, we can refer the tool above.
    You can develop a windows form application and use .Net Client Object Model to achieve it. The following articles is about how to operate the termset using Client Object Model for you reference:
    http://sundarnarasiman.net/?p=87 (Download)
    http://code.msdn.microsoft.com/office/SharePoint-2013-Synchronize-d40638d1/sourcecode?fileId=72317&pathId=166025385
    http://www.c-sharpcorner.com/Blogs/10853/how-to-create-a-term-set-for-the-specified-group-using-clien.aspx
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Automatic Gathering Statistics Script

    Hi,
    We must to schedule in our database some kind of job in order to monitoring the database and regularly gathering statitics of database objects (nowadays most of tables have been never analyzed). We have read the Oracle documentation in order to use the DBMS_STATS package but we are a bit confused about the enormous possibilities (gather_schema_stats, gather_table_stats,...=
    Could some one provide us some kind of help about the basics steps that should contain a simple script that could be scheduled daily in order to mantain fresh table statistics on database?
    Thanks

    Mmm. this docs refers to 10g version.
    We have 9.2.0.7 Standard EdtionYou neglected to mention that in your original post so one must assume that you are on a 'supported release' of oracle - which you aren't:
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_stats2.htm#1012974.

  • Exp/imp SYS objects

    hi all,
    I took a full export of database and I created a new database on another machine and I successfully imported the data.
    But there are some objects in the SYS schema which I want from the source database. So what should I do to export and import the SYS objects.
    I am using 9.2.0.5.0 version.
    Source database OS AIX.Target database OS is windows.
    Can anyone help on this ...
    thanks,
    ravi

    hi,
    I was already completed import with ignore=y option.But there r some errors because of different operating system.The major error numbers are
    23327,6512,2264,01 etc.
    I went through the meaning of all the errors.
    Imported terminated successfully with warnings(from import log).
    I think "with warnings" is because of the above errors and because of the different operating system.
    As you mentioned the 3rd point in your previous message,hw to go through exactly?
    thanks,
    ravi

  • How many space is used by an object

    Hi @ all,
    my english isn't very well but I hope you will understand me.
    I have to find out how many space is used by an object at runtime. The goal is to get information about the actual used space by an objectbuffer. (I mustn't use jvmpi or something else)
    Do you have an idea?
    best regards

    Try playing with the following code:
    import java.io.*;
    class IWantToBeMeasured implements Serializable {
        String[] stringArray = new String[1000]; //-- you'll waste at least 4 * 1000 bytes here...
        byte[] byteArray = new byte[1000]; //-- you'll waste at least 1000 bytes here...
        public IWantToBeMeasured() {
            //-- generate 1000 distinct strings "12345" // so you'll waste at least 5 * 1000 * 2 bytes here...
            for (int i = 0; i < stringArray.length; ++i) {
                stringArray[i] = String.valueOf (12345);
            //-- just fill 1000 bytes, and make all different, to avoid some optimizations
            for (int i = 0; i < byteArray.length; ++i) {
                byteArray[i] = (byte)i;
    class Test114 {
        public static void main(String[] args) {
            int estimatedObjectSize = -1;
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream ();
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                IWantToBeMeasured iwtbm = new IWantToBeMeasured ();
                oos.writeObject (iwtbm);
                oos.flush();
                estimatedObjectSize = baos.size();
                baos.close();
            } catch (IOException ex) {
            System.out.println ("Estimated object size = " + estimatedObjectSize);
    }It prints "Estimated object size = 9154".
    Well, do you expect a number that's greater than 15000 here. Why my program printed 9154?
    There is a problem here. I know that a string is stored in Unicode in memory, so each character must occupy 2 bytes. But strings are serialized in UTF-8 encoding, that use only 1 byte for each ASCII character. Then the program printed 9154 , that's yet smaller than 4000 + 5000 + 1000.
    I leave the problem to you.

Maybe you are looking for

  • IMac only boots in to Windows

    Hi My feonca got a copy of windows today and wanted me to install it for her. I created the partition using bootcamp setup the inserted the windows cd and rebooted. Competed the installation. Then I inserted the Leopard cd and ran the setup for the d

  • Accessories for Mac Pro

    Hi, guys. I have a problem here. I am looking for something that can protect against dust or something like that. Because my room is really not that clean, which means there's a lot of dust. I am worrying about the Mac Pro that will "eat" some dust.

  • Trying to download a song, but nothing seems to be happening (slow dial-up)

    I've been trying to download a song for at least half an hour on an ultra-slow dial-up connection (26.4 kbps), which is all that is available where I live, and there doesn't seem to be even one iota of progress so far. I don't know if anything is act

  • Network LOD support for All Paths between 2 nodes

    In the in-memory Network API, there is a method NetworkManager.allPaths. This method returns available paths between 2 nodes with possible constraints. I am looking for a similar method in the LOD NetworkAnalyst class and am not finding it. Is there

  • Specialty of supply function and  how can we use it efficiently?

    Hi Experts, I have one question. What exactly the function of "Supply function" for a node. Some says when ever lead change happens the "Supply function" triggers. I put a break point in Supply function say "ZSupply" written code to populate the tabl