Statistics automatically gathered on indexes?

I haven't paid much attention to this in the past, but I notice in XE that user_indexes
is automatically populated when you create an index - num_rows, last_analyzed,
etc. I suppose the simple act of creating the index collects enough data to
provide those statistics, and Oracle uses them instead of throwing them away.
Below is output from a simple script run in XE creating a table and four indexes.
user_indexes.last_analyzed is not null even without any explicit
gathering of statistics. num_rows, etc. are all populated...
This does NOT happen in Enterprise 9.2.0.4...
SQL> drop table pkt2;
Table dropped.
SQL> create table pkt2 as
2 select rownum row_num, rownum / object_id not_row_num, 2 * rownum / object_id not_row_num2
3 from all_objects
4 /
Table created.
SQL>
SQL> select table_name, last_analyzed from user_tables where table_name = 'PKT2';
TABLE_NAME LAST_ANAL
PKT2
SQL> create unique index pkt2_1_udx on pkt2(row_num);
Index created.
SQL> create index pkt2_2_idx on pkt2(not_row_num);
Index created.
SQL> create index pkt2_3_idx on pkt2(row_num, not_row_num);
Index created.
SQL> create index pkt2_4_idx on pkt2(row_num, not_row_num, not_row_num2);
Index created.
SQL> select index_name, last_analyzed, num_rows, leaf_blocks, clustering_factor
2 from user_indexes where table_name = 'PKT2';
INDEX_NAME LAST_ANAL NUM_ROWS LEAF_BLOCKS CLUSTERING_FACTOR
PKT2_3_IDX 27-NOV-05 4794 25 36
PKT2_4_IDX 27-NOV-05 4794 40 36
PKT2_1_UDX 27-NOV-05 4794 10 36
PKT2_2_IDX 27-NOV-05 4794 23 2322

that is normal behaviour in 10g

Similar Messages

  • Gathering Schema statistics automatically

    Hi All,
    I have a couple of doubts regarding automatic statistics gathering in Oracle 9i.
    I have seen a metalink document telling that in 9i statistics can be gathered automatically by giving options => 'GATHER AUTO'. My doubt is
    1) Once this statement is executed, dont we require running it any time afterwards? ie, will the statistics be gathered automatically for all objects in this schema without our intervention henceforth?
    2) It is mentioned to execute the following statement before the one above "exec dbms_stats.ALTER_SCHEMA_TAB_MONITORING('<owner>',TRUE);"
    If we enable table monitoring will it impact the database perfromance by any means? Will there be any overhead associated with table monitoring?
    Please clear my above doubts regarding the DBMS_STATS. Also could you please inform me which is the better way to gather object statistics for a schema.
    Thanks in advance
    Satish

    1) Yes, you need to create a job inside oracle (recommended) or a batch in your OS to calculate statistics in the interval (daily,weekly,etc) that you want. If you just execute it once only that time the statistics will be calculated.
    2)Yes, "it's recommended" but not mandatory. Except:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_stats.htm#sthref6562
    Well I think there will be some sort of impact, but I'm not sure how much. I once had that in a prod DB and I didn't noticed any kind of impact. You should test it before.
    I don't think there's a rule to know which way is better to gather statistics, because some options for DBMS_STATS applies for some cases and others for a complete different case.
    Depends in the type of DB that you have.

  • How to Gather Statistics of Tables and Indexes

    Hi all,
    Plz help me in Gathering Statistics of Tables and Indexes.
    Thanks

    for tables
    exec dbms_stats.gather_table_stats('SCOTT', 'EMPLOYEES');
    for indexes
    exec dbms_stats.gather_index_stats('SCOTT', 'EMPLOYEES_PK');
    check this link for detail
    http://nimishgarg.blogspot.com/2010/04/oracle-dbmsstats-gather-statistics-of.html

  • Update Statistics and Rebuild of Indexes

    Hi friends,
    If I execute the Update statistics for a given table thru DB20 does it have any effect on the indexes of this table or is it necessary to rebuild the index using db02
    Regards
    Aliila

    Updating Statistics does not rebuild index while in update states logs it will show you information regarding which indexes needs to be rebuiled which you can rebuild by brtools or executing rsanaora prg in se38.
    Shivam

  • Automatically incrementing an index

    There is a way to automatically increment a index in Oracle when a insert is carried out without calling a trigger. But I cannot remember how to do it.
    So if I have emp_id as the primary key for the table emp, the last one is set to 105, when I do an insert on emp oracle will automatically set it to 105
    Thanks for any help Tony

    Are you talking about using a sequence ?

  • SQL Developer Behavior When Gathering Table/Index Statistics

    Hey All,
    Not sure if this has been posted yet. I did a search and did not find any threads on the topic though.
    I noticed with SQL Developer 2.x, when you using the context menu to gather table/index statistics for a given table, you get no modal progress/waiting window like you did in 1.x. It just kind of "does nothing", even though it did actually execute the DBMS_STATS package. If you press cancel and try to navigate around, you get multiple "Connection is Busy" errors. Eventually it will come back and say "Statistics gathered for table <whatever>". In the old versions there was just a modal window with an animated progress bar while it ran the DBMS_STATS package. What happened to that? Or is this something unique to my install? Anyone else ran into this? Is there a fix or somewhere I can report this as an official bug? FWIW I'm running 2.1.1.64, and this did occur in the initial 2.0 release.
    It is very confusing the first time you run into it... I pressed the "apply" button several times thinking it didn't take, but it ended up running the DBMS_STATS for every click I did.
    Thanks!

    Same happens to all the other context menu opened dialogs. Indeed very confusing at first and disturbing.
    The only official site to report bugs is Metalink/MOS, but you might be lucky if someone from the team picks it up here.
    Regards,
    K.

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

  • Compute Statistics after create a index

    Good night, I tryed it before and got no help.
    So I'll try it again, because I didn't find it yet.
    I have to create some indexes in a production database.
    I have a doubt.
    Do I need to Compute Statistics after creating indexes?
    Or when I create they automatically are computed?
    Thanks for any help.
    The version I'm using is:
    Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
    PL/SQL Release 10.2.0.5.0 - Production
    CORE     10.2.0.5.0     Production
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production

    Petri BR wrote:
    Good night, I tryed it before and got no help.
    So I'll try it again, because I didn't find it yet.
    I have to create some indexes in a production database.
    I have a doubt.
    Do I need to Compute Statistics after creating indexes?after CREATE INDEX what are the values for the index statistics?
    Or when I create they automatically are computed?Just look at the statistics values after issuing CREATE INDEX & answer the question yourself!

  • BW, BRTools, statistics, monitoring and bitmap indexes.

    Hi all, I have a question about the above.
    Oracle 10.2, Solaris 10, BW 7.00
    We have a script that generates statistics weekly on our systems.  lately, I have been noticing the following messages in the output after the BRTools statistics job is run:
    BR0988W Bitmap index "Index_name" selected for checking statistics - please activate the monitoring attribute for table "Table_name"***
    After reading SAPNotes 442395, 588688 & 408527, doing searches of SAPNotes, this forum and other forums such as ITToolbox, the answer to the above is "activate monitoring for the above/all tables".  I get this.
    My issue is that after seeing warnings or missing/skipped statistics, I will manually run the following
    brconnect -u / -c -f stats -t all -p 4 as the SID_ORA user
    When I do that, the warning message (BR0988W) does not appear in the output.  And if I check the table in Oracle with something like the following:
    select tablespace_name, table_name, partitioned, monitoring from all_tables where table_name = '"Table_name"';
    The ouput is
    TABLESPACE_NAME                TABLE_NAME                     PAR MON
    "Tablespace_name"                 "Table_name"                   YES YES
    which shows that monitoring is activated for the table.
    My question is, by running "brconnect -u / -c -f stats -t all -p 4" was monitoring turned on?  This would mean that I would not have to run the script suggested in 408527.  Or can the BR0988W error be generated even though monitoring is activated.
    The next time I see the error in the statistics output, I will run the SQL and check the status of the table before running the BRTools stats update.
    Table_name and Index_name are just generic markers.  I have checked and confirmed that I have not mistyped actual names when running select statements.

    As far as i know this message is outdated with 10g.
    Please have a look at this discussion: DB13 - Update Sttats - activate the monitoring attribute for table
    Cheers Michael

  • Oracle Automatically creates some indexes.

    Hi,
    In my database on several table on some non indexed columns , oracle automatically creates indexes which start with naming convention 'XIF'.
    what are this indexes? and what is benefit with it? is there any way to stop this?
    Thanks

    HI,
    thanks for reply,
    its actually non oracle user,
    see the below output
    select index_name,table_name,owner from dba_indexes where index_name like 'XIF%';
    INDEX_NAME TABLE_NAME OWNER
    XIF582TBLMGROUP TBLMGROUP JISPBILCORBILLINGSQA510
    XIF439TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF440TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF1006TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF1070TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF140TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF141TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF228TBLMACCOUNT TBLMACCOUNT JISPBILCORBILLINGSQA510
    XIF210TBLMACCOUNT     TBLMACCOUNT JISPBILCORBILLINGSQA510
    above indexes are automatically created, for application server we are using Oracle Application Server as well as JBOSS.

  • Automate command to index in 11G

    Hi,
    We're going through manual migration of our 5.2 instances over to 11g, and have a big list of indexed attributes. It is really a tough jobs to run multiple commands per suffix across various environment. I was wondering if someone has a better way to help me out.
    Thanks, John.

    For initial system configuration, I usually put my index configurations in an LDIF and then replace all the non-system indexes with mine. As long as you do this before an LDIF import that's about all there is to it. Of course there are dsconf commands to do it too if you want to go that way. If you are initializing data from a binary backup, you just need to make sure the backup comes from a system with the same indexes. IIRC the restore will fail if that's not the case.
    If what you are talking about is a multi-system reindex utility intended to change existing indexes on multiple systems that are currently in service, you need to be very careful with that. Since reindexing puts the backend into readonly, that kind of tool will have the potential to put an entire topology into readonly, with an associated topology-wide write outage. We had a thread about that a while back. If this forum's search tools worked better, I'd probably be able to fish that out for you.

  • Gathering statistics on interMedia indexes and tables

    Has anyone found any differences (like which one is better or worse) between using the ANALYZE sql command, dbms_utility package, or dbms_stats package to compute or estimate statistics for interMedia text indexes and tables for 8.1.6? I've read the documentation on the subject, but it is still unclear as to which method should be used. The interMedia text docs say the ANALYZE command should be used, and the dbms_stats docs say that dbms_stats should be used.
    Any help or past experience will be grateful.
    Thanks,
    jj

    According to the Support Document "Using statistics with Oracle Text" (Doc ID 139979.1), no:
    Q. Should we gather statistics on the underlying DR$/DR# tables? If yes/no, why?
    A. The recommendation is NO. All internal recursive queries have hints to fix the plans that are deemed most optimal. We have seen in the past that statistics on the underlying DR$ tables may cause query plan changes leading to serious query performance problems.
    Q. Should we gather statistics on Text domain indexes ( in our example above, BOOKS_INDEX)? Does it have any effect?
    A: As documented in the reference manual, gathering statistics on Text domain index will help CBO to estimate selectivity and costs for processing a CONTAINS() predicate. If the Text index does not have statistics collected, default selectivity and cost will be used.
    So 'No' on the DR$ tables and indexes, 'yes' on the user table being indexed.

  • 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/

  • Statistics gathered during import

    Does after IMP import the tables are analyzed automatically?
    When i done import process of TEST user
    imp system/manager file=/home/oracle/test.dmp FROMUSER=TEST TOUSER=TEST
    and when i execute following query
    SELECT table_name,last_analyzed FROM DBA_TABLES WHERE owner=TEST'
    I find that table/indexes are analyzed automatically.
    Does it means statistics are gathered automatically during import?
    Oracle 10.2.0.1

    Refer to this link please
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/exp_imp.htm#i1020893
    It seems it takes statistics for tables during export
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Dbms_stats or automatic statistics.

    Hi members,
    We are using 10g database. I am aware that 10g collects statistics automatically using its job scheduling process. Do we still need to schedule statistics collection using dbms_stats or analyze on our 10gR2 database? Is it redundant? In what situations is it required?

    You either want statistics to be gathered by the Oracle background job (which is calling dbms_stats) or you want to control statistics gathering via a job you control. Having both would be, at best, redundant, and would likely eventually cause problems.
    There is probably an 80/20 rule here. 80% of organizations with 80% of the databases probably want to keep the default settings. For the remaining 20%, you may want to change the DBMS_STATS default settings (i.e. you may need to gather fewer histograms). You may want to gather stats as part of your nightly loads (i.e. a data warehouse). You may have a preferred scheduling tool that is not the database that you want to control statistics gathering for operational reasons.
    As an aside, you should not be using ANALYZE to gather object statistics. That has been depricated for quite some time.
    Justin

Maybe you are looking for