Analyzing tables

What is analyzing of a table? How i can do it? What is the advantage of doing it?
Please advice,
Regards,
Arun Kumar

What is analyzing of a table? How i can do it? By default in V10+ statistics are gathered once a day for objects which changed by more than 10% or so.
What is the advantage of doing it?The Cost Based Optimizer makes better decisions when it knows the distribution of data.

Similar Messages

  • Analyze Table required on a Global Temp. Table

    Hi,
    This is the background. We have a Windows reporting Oracle Server where we write stored procedures to access data mainly based off a warehouse residing on a unix box. DBLinks have been setup and synonym's created .
    We create Global Temp. Tables to store temp. data used by our report stored procedures. I have one query that accesses 5 remote tables and one local table
    The query was taking hours to run...after some research i found out that when I did an "Analyze Table" on my Global temp. table, the query came back in a few minutes.
    My confusion is that this table being a GTT.. it will always be empty when we run "Analyze Table" on it. What information is oracle? Do we need to run "analyze table" on all our GTT's created for different reports?
    Second question on show query plan
    Also if I do a query plan on this query ORacle dooes not provide a plan on the remote tables. If i change the query by removing the reference to the local table and hardcoing some vlaues, oralce returns a query plan for the query which now only uses the remote tables. Is this correct?

    Hi,
    you can fake the statistics of the temporary table.
    First create a real table (with indexes) that looks like the temporary table. Load the table with representative data.
    Then
    dbms_stats.gather_table_stats(ownname=>'schemauser',tabname=>'TEMPCOPY');
    dbms_stats.create_stat_table(ownname=>'schemauser',stattab=>'TEMPSTATS');
    dbms_stats.export_table_stats(ownname=>'schemauser',tabname=>'TEMPCOPY',stattab=>'TEMPSTATS'); --do that for every index
    dbms_stats.export_index_stats(ownname=>'schemauser',indname=>'INDEXNAME',stattab=>'TEMPSTATS');Now we import the generated statistics:
    dbms_stats.import_table_stats(ownname=>'schemauser',tabname=>'TEMPTABLE',stattab=>'TEMPSTATS');
    dbms_stats.import_index_stats(ownname=>'schemauser',tabname=>'TEMPTABLE',stattab=>'TEMPSTATS'); --for every indexOf course you can create a set of statistics and load them as needed.
    Dim
    dbms_stats.

  • Analyze table

    Dear all,
    What are the advantages if we do
    analyze table <table name> compute statisticsWhen ever i run this it is computing huge CPU utilization and taking long time........
    if we do this as far as i know
    1)it will analyze the table and count number of rows in a table properly.......
    Is there any advantage for INDEX if we do this operation.
    Regards,
    Vamsi

    Hey,
    Actually this command is old. I think it is 9i and below; It is still there for backwards compatibility.
    Since you are computing the statitics, oracle is going over all the records to get the stats. You can do estimate statics instead.
    OR, even better, you can use the new DBMS_Stats Package:
    EXEC DBMS_STATS.GATHER_TABLE_STATS (ownname=>'SCHEMA_NAME', tabname => 'TABLE_NAME', estimate_percent=>dbms_stats.auto_sample_size, degree=>2);
    This uses DBMS stats package, to estimate the statistics via a sample size automatically set through oracle.
    You can also use a similar command to estimate the stats of the whole schema
    EXEC DBMS_STATS.GATHER_SCHEMA_STATS (ownname=> 'SCHEMA_NAME', estimate_percent=>dbms_stats.auto_sample_size, degree=>2);
    From previous experience, creating an index is not enough, you have to gather the stats on the related table, so that the execution plan gets optimized.
    This command get table stats, histogram, uniqueness.. etc

  • Analyze table in oracle 8.1.6

    Hi,
    I am working in oracle 8.1.6 on unix.the optimizer used here is RBO. I need to analyze a table using the command "analyze table <tablename> compute statistics; but my team mate said that the using anlyze table will degrade the performance.
    how can i analyze a table without affecting the performance?...
    give me an example..
    rgds..

    user537350 wrote:
    hi,
    i did defrag table using the command alter table move tablespace then rebuild the indexes and then analyze the table.
    while doing the analyze of table my teammate said it will degrade the performance?..how can i proceed ..First, I wouldn't just blindly assume I have a problem to be fixed just because "my teammate" said that what I did would degrade performance. Did he have a valid theory to back up his assertion? Why not actually measure performance and see if it degraded?
    BTW, I assume you realize that your vesion of oracle is totally unsupported in this millenium .... which means your organization doesn't value the data in the database.
    Edited by: EdStevens on Aug 12, 2009 10:46 AM

  • Where is the output of analyze table name validate structure cascade

    Hi,
    database version:8.1.7.0.0
    os :solaris 5.9
    since i used to get ORA-00600: INTERNAL ERROR CODE, ARGUMENTS: [25012], [7], [39] and i need to validate the table and this table is very huge(200 gb) where will be the output generated if any error is there in table including indexes.
    sql>analyze table event_t validate structure cascade;
    Regards
    Prakash

    Hello Helios
    sorry ,
    I am using 10.2 and reviewing
    http://docs.oracle.com/cd/B14117_01/server.101/b10759/statements_4005.htm#sthref4205
    my quote is from this document. My question of an ideal case, when there is no block corruption
    regards ,
    Pavel
    Edited by: Pavel on Oct 17, 2012 3:55 AM

  • ORA-20000: Unable to analyze TABLE "ECI"."COUNTRY"

    Oracle9i 9.2.0.7 on Windows Server 2003 32bit
    Using the "ANALYZE" in the Enterrpise Manager Console
    begin
    dbms_stats.gather_table_stats(ownname=>'ECI',tabname=>'COUNTRY',partname=>NULL);
    end;
    ORA-20000: Unable to analyze TABLE "ECI"."COUNTRY", insufficient priviledges or does not exist
    ORA-06512: at "SYS.DBMS_STATS", line 10292
    ORA-06512: at "SYS.DBMS_STATS", line 10315
    ORA-06512: at line 2
    Using SQLPLUS
    SQL>begin
    2>dbms_stats.gather_table_stats(ownname=>'ECI',tabname=>'country',partname=>NULL);
    3>end;
    4>/
    ORA-20000: Unable to analyze TABLE "ECI"."COUNTRY", insufficient priviledges or does not exist
    ORA-06512: at "SYS.DBMS_STATS", line 10292
    ORA-06512: at "SYS.DBMS_STATS", line 10315
    ORA-06512: at line 2
    COMMENT:I noticed here that eventhough I specifically used (tabname=>'country') it still used "ECI"."COUNTRY"(ALL CAPS) in executing my statement
    I also tested on other procedure.
    Using SQLPLUS
    SQL>begin
    2>dbms_redefinition.can_redef_table('ECI','country',dbms_redefinition.cons_use_pk);
    3>end;
    4>/
    BEGIN
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 8
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 247
    ORA-06512: at line 2
    I don't understand why this error happens because
    a) the schema and table exist (I double checked)
    b) the error only happens on a single schema for only the old tables, when I create new tables I could "ANALYZE" it. I also can "ANALYZE" the indexes.
    c)I have used both the sys and system user logging in as SYSDBA
    In the ff exercise, I noticed that "ECI"."productrange" will work but "ECI"."PRODUCTRANGE" won't:
    SQL>select count(*) from "ECI"."productrange";
    COUNT(*)
    8
    SQL>select count(*) from "ECI"."PRODUCTRANGE";
    select count(*) from "ECI"."PRODUCTRANGE"
    ERROR at line 1:
    ora-00942: TABLE OR VIEW DOES NOT EXIST
    Can anyone kindly help me?

    You should not be creating tables in Oracle with names enclosed in double quotes. In that case Oracle preserves the case, making it difficult for others to identify the table.
    Create the table without using double quotes (may be CTAS) and everything should work fine.

  • Analyze table after insert a large number of records?

    For performance purpose, is it a good practice to execute an 'analyze table' command after inserting a large number of a records into a table in Oracle 10g, if there is a complex query following the insert?
    For example:
    Insert into foo ...... //Insert one million records to table foo.
    analyze table foo COMPUTE STATISTICS; //analyze table foo
    select * from foo, bar, car...... //Execute a complex query whithout hints
    //after 1 million records inserted into foo
    Does this strategy help to improve the overall performance?
    Thanks.

    Different execution plans will most frequently occur when the ratio of the number of records in various tables involved in the select has changed tremendously. This happens above all if 'fact' tables are growing and 'lookup' tables stayed constant.
    This is why you shouldn't test an application with a small number of 'fact' records.
    This can happen both with analyze table and dbms_stats.
    The advantage of dbms_stats is, it will export the current statistics to a stats to table, so you can always revert to them using dbms_stats.import_stats.
    You can even overrule individual table and column statistics by artificial values.
    Hth
    Sybrand Bakker
    Senior Oracle DBA

  • OWB ORA-2000 unable to analyze table

    During execution I received the error above. In the mapping, I have two targets in two different schema's. I receive the error on the target that is in a different schema than the mapping.
    Is there a workaround? We do not have rights to grant analyze any table to the schema owner of the mapping.

    In OWB select Mapping, context menu Properties -> Code generation options -> Change Analyze table statements to false.
    Bye
    Detlef

  • ORA-04092 trying to analyze table

    Hi,
    I was trying to analyze some tables issuing:
    analyze table owner.table_name compute statistics;
    Immediately raises the ora-04092, as far as I seen, read, and googled, this ORA error occurs only when someone try to commit inside a trigger, but clearly this is not the case.
    And even in some web applications this error appears.
    This error started to occur after session limit exceeded, doesn't sound related to me, but maybe it can be interesting information.
    Any suggestions please, I'm comfused.
    Regards

    Here more information:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SO: RHELAS 5
    And according recomendation, I tryed to use DBMS_STAT, with same results:
    SQL> conn system/*******@siin
    Connected.
    SQL> conn mailedu/*******@siin
    ERROR:
    ORA-04092: cannot COMMIT in a trigger
    ERROR:
    ORA-24315: illegal attribute type
    Warning: You are no longer connected to ORACLE.
    SQL> conn mailedu/********@siin
    ERROR:
    ORA-24315: illegal attribute type
    SQL> conn system/********@siin
    ERROR:
    ORA-24315: illegal attribute type
    Once I restart sqlplusw, and I could connect (just the first connect is successfull) I tryed with dbms_stats:
    SQL> exec dbms_stats.gather_schema_stats ( -
    ownname => 'MAILEDU', -
    options => 'GATHER' );BEGIN dbms_stats.gather_schema_stats ( ownname => 'MAILEDU', options => 'GATHER' ); END;
    ERROR at line 1:
    ORA-04092: cannot COMMIT in a trigger
    ORA-06512: at "SYS.DBMS_STATS", line 14002
    ORA-06512: at "SYS.DBMS_STATS", line 13974
    ORA-06512: at line 1
    Looking further inside the forum I found this thread:
    stupid ora-04092 error message
    In the conversation it is mentioned that according document Link:[7886990|https://metalink.oracle.com/CSP/ui/flash.html#tab=KBHome(page=KBHome&id=()),(page=KBNavigator&id=(bmDocDsrc=Bug&bmDocTitle=AFTER%20OCCURRING%20ORA-18,%20ORACLE%20THROWS%20ORA-4092%20CONTINOUSLY&bmDocID=7886990&viewingMode=1143&from=BOOKMARK&bmDocType=BUG))]
    it can occur after ORA-00018 maximum number of sessions exceeded
    this one is my scenario,
    And...
    Bug No: 6977167
    Filed 16-APR-2008 Updated 19-AUG-2009
    Product Oracle Server - Enterprise Edition Product Version 10.2.0.2
    Platform Linux x86-64 Platform Version rel4
    Database Version 10.2.0.2 Affects Platforms Generic
    Severity Severe Loss of Service Status Development to Q/A
    Base Bug N/A Fixed in Product Version 11.2
    So I would like to mark this as a known bug, but I don't know how to proeced.
    Regards

  • Sql slow afterweekly STATS-JOB,then run analyze table it is fast again

    Oracle R11.2.0.2 :
    I hade some slow sql / reports and found the effect,
    that the sql is slow obvious after the weekend ,
    when STATS - JOB BSLN_MAINTAIN_STATS_JOB and other Jobs were running weekly on SYS.
    I did run dbms_stats.GATHER_TABLE_STATS on schema
    it doesn't help.
    But when
    run ANALYZE TABLE afterwards on only one or two tables of the schema
    the sql / reports performance is well and fast.
    in the dba_tables I can see the last_analyze - date
    and in GLOBAL_STATS = NO ( when Table runs with ANALYZE ),
    GLOBAL_STATS = YES( when Table runs with STATS )
    what does the ANALYZE TABLE command doing good and let my sql run well and fast,
    while dbms_stats.GATHER_TABLE_STATS
    seems not work well in this situation ?
    regards

    astramare wrote:
    Oracle R11.2.0.2 :
    I hade some slow sql / reports and found the effect,
    that the sql is slow obvious after the weekend ,
    when STATS - JOB BSLN_MAINTAIN_STATS_JOB and other Jobs were running weekly on SYS.
    I did run dbms_stats.GATHER_TABLE_STATS on schema
    it doesn't help.
    What options do you use for the gather_stats command ?
    Do you also have collected system stats?
    But when
    run ANALYZE TABLE afterwards on only one or two tables of the schema
    the sql / reports performance is well and fast.Analyze table is deprecated, but still does its work for some part. It is not as complete as dbms_stats
    >
    in the dba_tables I can see the last_analyze - date
    and in GLOBAL_STATS = NO ( when Table runs with ANALYZE ),
    GLOBAL_STATS = YES( when Table runs with STATS )
    It must have to do something with the way you use it..
    HTH
    FJFranken

  • Question about Analyze Table

    Hi Guys,
    I am creating an Oracle Job that performs two tasks:
    1.) Delete record from a Table A older than 30 days.
    2.) Perform Analyze Table to the Table A after deleting records.
    The thing that makes me think is that aside from the job I'm creating, there are other jobs/processes that accesses Table A.
    Will there be any problem that may occur once my job performs the Analyze Table to Table A and other jobs/process are also accessing Table A concurrently (e.g. inserting, querying)?
    I'll surely appreciate any idea from you guys!
    Thanks,
    Jay

    Other than the IO load that it causes, the ANALYZE statement has no effect on other sessions while it is running+.
    However, on completion, it will invalidate all SQLs referencing that table. All new invocations of SQLs will need re-parsing and may generate a new Execution Plan, different from those for the same statements before the ANALYZE. Rrunning SQLs already begun will continue running until they complete.
    If you have a job / session / application that frequently queries the table, you might suddenly see a change in execution plan for those queries after the ANALYZE completes.

  • ANALYZE TABLE ... VALIDATE STRUCTURE

    I did ANALYZE TABLE ... VALIDATE STRUCTURE CASCADE. MetaLink says output
    is in trace file in udump location. Well it is not. Does anyone
    know where Oracle does hide this info?

    Oracle is not hiding anything.
    There will be only info when there is something wrong.
    Rather than discussing irrelevant issues like defragmenting tablespaces, rebuilding indices etc,etc why don't you start reading the documentation?
    You seem to have too much time on your hands.
    Sybrand Bakker
    Senior Oracle DBA

  • Question about "ANALYZE TABLE VALIDATE STRUCTURE" in 9i

    Hi,
    I have a 9.2.0.8 database on AIX. After a storage copy of my produztion datafiles from a site to another I performed a DBV to ensure that all copies were correct. After I correctly started my db.
    Now, could be a good idea to perform a "ANALYZE TABLE tabname VALIDATE STRUCTURE;" statement on all table of my database to be sure that I haven't a corruption? Are there cons performing this operation?

    Insaponata wrote:
    Hi,
    I have a 9.2.0.8 database on AIX. After a storage copy of my produztion datafiles from a site to another I performed a DBV to ensure that all copies were correct. After I correctly started my db.
    Now, could be a good idea to perform a "ANALYZE TABLE tabname VALIDATE STRUCTURE;" statement on all table of my database to be sure that I haven't a corruption? Are there cons performing this operation?IMO its needless.
    Just take full backup through RMAN, and validate that backup.
    regards

  • What analyze table command will do exactly?

    Hi,
    Can any one tell me what this analyze table command will do when we execute it??? Please help me out.
    Cheers,
    Senthil

    Which database version?
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4005.htm#i2086320
    See the NOTE on that link.
    Basically, unless there is a bug in DBMS_STATS where the recommended workaround is to use ANALYZE use DBMS_STATS instead.

  • Analyze table command

    what is Analyze table command,please clear with example,using this command how to find how many rows in table

    Manual pages for Analyze command.
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4005.htm#i2086320
    Pay special attention to the part where it says Oracle strongly recommends using dbms_stats package from now on instead of analyze.
    You can find out the number of rows in the table by doing a select count(*) from the table. Or, if the most recent statistics are good enough, you can look at user_tables (in the num_rows column).

  • Analyze table hangs for hours

    Hi,
    Analyze table hangs for hours (more than 6 hrs) using DBMS_STATS.GATHER_TABLE_STATS.At last we killed the session and then rerun it.it runs succesfully completed.
    Why DBMS_STATS.GATHER_TABLE_STATS hangs for hours for some time?
    is this issue arise due to the GATHER_STATS_JOB schedule or any other issue?
    please help me.
    Thanks,
    Michael Holding

    holding wrote:
    Analyze table hangs for hours (more than 6 hrs) using DBMS_STATS.GATHER_TABLE_STATS.At last we killed the session and then rerun it.it runs succesfully completed.It could have been waiting on a locked table when killed. And then when restarted, it could have found the table unlocked.
    Why DBMS_STATS.GATHER_TABLE_STATS hangs for hours for some time?As Boneist said.. the wait states and events of the session would have shed light on that.
    is this issue arise due to the GATHER_STATS_JOB schedule or any other issue?Dunno... insufficient data to accurately compute. (except for making guesses like above with table being locked and then unlocked)
    please help me.Don't kill a "+stuck/hung+" session before looking at what it is busy with (events) and what it is waiting on (wait state)?

Maybe you are looking for

  • Baseline Date Issue

    Dear Experts, I am facing a peculiar problem. In the payment terms configuration i have mentioned Posting Date as the baseline date. The invoice is created in our company when the goods are dispatched. At this point only the invoice is made and accou

  • Can I transfer my itunes from one laptop to another?

    Can I transfer my itunes from one laptop to another?

  • Lion 10.7 Only Boots in Safe Mode. Is This a Hardware or Software Issue?

    Hi. On my iMac late 2009 i7 8GB bought last March only. I reinstalled Lion (I didn't erase the whole disk because I have Boot Camp Windows and I have filed there) and it can only boot in safe mode if I use the Mac's built-in EFI bootloader (where you

  • Slow to open PDF files in Adobe Reader

    Hello, after upgrading to Mac OS 8.5.3 and 10.9 Maverick'm slow to open PDF files from a Windows 2003 Server share. In the terminal I get the following errors Print Screen below. PING to the IP of the share is less than 1 ms. I'm working with adobe r

  • Unable to Install 10.6.5

    I can download the 10.6.5 update, but when i go to install it, it gets to about halfway and then stops. I get a message saying error: unable to install selected updates. Can anyone help me out?