Table Defragmentation

Hi ,
Recently we had performed table defrgamention on 9i oracle database on linux platform . we did fragmentation for around 20 tables , out of which 10 tables size decrease , 5 tables didnt got affected and to my surprise 5 tables got increased by 8 mb each ? deframention is not there should not increase the size . We even queried dba_tab_modifications and to my surprise there is no inserts ,updates or deltes on those tables ? so just wondering how did the table size increase .
Pleae Oracle Guru's give your thoughts and inputs on this .
Thanks & Regards ,
Edited by: 967462 on 24 Oct, 2012 11:08 AM

John and Jonathan have covered it pretty well (read Jonathan's article then read it again-- very good).
What you did was, basically, to attempt to get every block in every table full to roughly the PCTFREE setting of the table (glossing over the fact that you likely have a few partially filled blocks). If your starting point was a table that had lots of mostly empty blocks (that would have been filled up by subsequent INSERT statements), the size of the table will go down. If your starting point was a table that had lots of mostly full blocks (i.e. blocks where there was less free space than the PCTFREE setting), the size of the table will go up.
If your PCTFREE is set correctly and unless you have some pathological patterns in your data flows-- for example, you're only ever doing direct-path loads so empty blocks are never reused-- or unless you need to permanently reclaim some space following a large, one-time DELETE, it should be very rare that there should be any reason to do an ALTER TABLE MOVE for "defragmentation". Tables don't get fragmented so there is nothing to defragment. You might do a lot of work to reuse space today that was going to get reused organically in the very near future but that's generally the best case.
Justin

Similar Messages

  • Will alter table table_name move statement change the storage parammeter

    Hi there,
    I have a question about table reorgnization. Will alter table
    table_name move SQL statment change the table's storage parameter
    or keep the same as the original one? If I want to use alter
    table statement to do table defragmentation and change the
    initial and next storage parameter, how will I write this SQL
    statement?
    Thanks in advance.

    Thanks. My table has 5000 extents each of which is 64k, so I
    think I need to do table defragmentation to improve performance.
    If I use alter table table_name move without storage parameter
    and tablespace name, I will relocate this table in current
    tablespace and adopt the current tablespace's storage parameter
    as my table's new storage paramater which is still 64k. After
    that, if I issue alter
    table table_name storage (initial 50M next=50M) command, will it
    change this table's storage parameter and decrease the totoal
    extents number? I ask this question because I use OEM2.2 tuning
    pack reorg wizard to generate the job script to do table
    defragmentation, but in the job script there is no new storage
    parameter. It only generate alter table table_name move
    statement, so I wonder if I don't need to modify this job scripts
    and after it executes this job script, I issue alter table
    table_name storage parameter command manaully. Will this solve
    my problem or I must modify the job script and add new storage
    parameter in the job script?

  • Impact of ALTER TABLE .. MOVE

    Hi :
    Can any one tell me the impact of running this statement.
    One of my dev wants to include this in his scripts to avoid table defragmentation.
    He has rewritten a query that deletes and inserts new records instead of updating the records. Select statments are slower due to fragmented tables. The above command shrinks the table and hence faster response time.
    - Any negative impacts that u may think of would be appreciated.
    Regards,
    - BMP

    Are u talkikng about the Block setting parameters
    like PCTFree, PCTUSED and Highwater marks'Right you haven't mention which version you are working on.
    I think what Hans means is not PCTFree or PCTUsed, it's not really a big concern since LMT.
    Queries like Update and Delete are not explicit SELECT statements but they all have the implicit queries (subqueries) in the statements.
    The slowness is mostly from the subqueries. You need find out why update subquery is slower than delete subquery. There's no apparent reason why update is slower than delete. Because they all need to use subquery to identify targeting rows and take action.

  • Reorganization of the database (defragmentation of tables).

    Hi All ,
    Can anyone tell me how much approximate time do we require for reorganization of the database(defragmentation of tables) .
    DB size is 300Gb . I think there is a package called dbms_redefinition for this job? Correct me if i am wrong
    Os version : AIX 5L Databse : 11g
    Our client want to carry out this task on weekend and they need approx time window require to do this.
    Thanks in advance

    You're on 11g, so you're presumably using locally managed tablespaces (LMTs). If so, that makes it practically impossible to have "fragmentation" in tables, at least for any practical definition of "fragmentation". So my first response would be 0 time, the tables don't need to be defragmented.
    If you plan on using the DBMS_REDEFINITION package, be aware that you'll need enough space for another copy of each table (i.e. potentially another 300 GB of disk space if you plan on running in parallel).
    Justin

  • How to remove fragmentation in a table?

    How to find fragmentation in a table?
    How to remove fragmentation in a table?

    Hi,
    sa_index_density --gives the density of stored procedure.
    sa_table_fragmentation-- degree of fragmentation in stored procedure table.
    REORGANIZE THE TABLE -- DOES NOT DISTURB THE DATABASE ACCESS
    REBUILD DATABASE -- DEFRAGMENTS ALL TABLES, INCLUDING SYSTEM TABLESPACE.
    Regards,
    Nirmal([email protected])

  • Recreating a table with child table dependencies

    Hi.
    I have two tables P (Parent) and C (child), with foreign key dependencies. How can I recreate the P table without losing the child dependencies?
    Thanks in Advance.

    934086 wrote:
    Well I got this as an interview question. So what I guess what it means is to recreate the table for administrative purposes (maintenance/defragmentation etc) and later recreate the dependencies in to the C table.If this is a good interviewer, they will be expecting you to ask some questions to find out the restrictions on what you're allowed to do.
    Obviously you could extract any dependency information from the data dictionary, so it won't be "lost". Then you could switch the database into restricted mode and/or shut down the listener. Drop any RI constraints, recreate table, recreate constraints, restart listener, take database out of restricted mode. However, this might be a catastrophic strategy from the perspective of the business - so if you try to answer the question without first asking questions (or at least starting with "there are various methods, depending on the restrictions you need to impose from a business perspective, for example ...)
    Regards
    Jonathan Lewis

  • Re - Oraganize table in Oracle 11 G

    Hello,
    We are planning to re-oraganize a few tables (includig parttioned tables).I understand how to re- org a non - partioned table. like below
    SQL> ALTER TABLE owner.TABLENAME MOVE;
    Table altered.
    SQL> ALTER INDEX owner.INDEX REBUILD;
    Could some one help on how partioned table needs to be re- organized in 11 G database.
    Also I see when i re- organize a non - partioned table I found the tablespace usage has gone up to 70 % usage of table size and once the defragmention is done the space is released,why is that so..?
    Thanks
    Soundar M
    Edited by: soundar on Jun 5, 2013 11:43 PM
    Edited by: soundar on Jun 5, 2013 11:44 PM

    My understanding is, for partitioned table you need to move/rebuild each table partition (and its corresponding index) saperately. Command would be "ALTER TABLE ... MOVE PARTITION ...".
    I wonder if there is a facility to rebuild partitions of same table in parallel with one single command.
    Regarding space occupied by segment, concept of high water mark is important here. That decides how much space is occupied.

  • Question about "fast fsck", ext4 and defragmentation status [SOLVED]

    I'm trying to use fsck to do a defacto defragmentation check of an ext4 partition. I'm running fsck from a live cd (SysRescue 1.15) to check one of my ext4 partitions. The ext4 partition is unmounted, of course.
    The check goes amazingly fast, but it doesn't give me any info about the percentage of non-contiguous inodes, which I understand to be the the same as the percentage of defragmentation (true?). I'm thinking this is because of the new "fast fsck" feature of ext4, as detailed below.
    My question: can I force a "slow fsck" in order to get a complete check including the inode-contiguity info? Or is there another way to get at the defragmentation status using fsck?
    Thanks.
    FWIW, here's the info on "fast fsck" from the excellent http://kernelnewbies.org/Ext4 page:
    2.7. Fast fsck
    Fsck is a very slow operation, especially the first step: checking all the inodes in the file system. In Ext4, at the end of each group's inode table will be stored a list of unused inodes (with a checksum, for safety), so fsck will not check those inodes. The result is that total fsck time improves from 2 to 20 times, depending on the number of used inodes (http://kerneltrap.org/Linux/Improving_f … ds_in_Ext4). It must be noticed that it's fsck, and not Ext4, who will build the list of unused inodes. This means that you must run fsck to get the list of unused inodes built, and only the next fsck run will be faster (you need to pass a fsck in order to convert a Ext3 filesystem to Ext4 anyway). There's also a feature that takes part in this fsck speed up - "flexible block groups" - that also speeds up filesystem operations.
    Last edited by dhave (2009-02-17 22:09:49)

    Ranguvar wrote:
    Woot! http://fly.isti.cnr.it/cgi-bin/dwww/usr … z?type=man
    fsck.ext4 -E fragcheck /dev/foo
    Thanks, Ranguvar. I had read the man page for fsck.ext3, but I hadn't run across the page for fsck.ext4. The link was helpful.

  • Index size greater than table size

    HI ,
    While checking the large segments , I came to know that index HZ_PARAM_TAB_N1 is larger than table HZ_PARAM_TAB . I think it's highly fragmented and requires defragmentation . Need your suggestion on the same that how can I collect more information on the same . Providing you more information .
    1.
    select sum(bytes)/1024/1024/1024,segment_name from dba_segments group by segment_name having sum(bytes)/1024/1024/1024 > 1 order by 1 desc;
    SUM(BYTES)/1024/1024/1024 SEGMENT_NAME
    81.2941895 HZ_PARAM_TAB_N1
    72.1064453 SYS_LOB0000066009C00004$$
    52.7703857 HZ_PARAM_TAB
    2. Index code
    <pre>
    COLUMN_NAME COLUMN_POSITION
    ITEM_KEY 1
    PARAM_NAME 2
    </pre>
    Regards
    Rahul

    Hi ,
    Thanks . I know that rebuild will defragment it . But as I'm on my new site , I was looking for some more supporting information before drafting the mail on the same that it requires re org activity .It's not possible for an index to have the size greater than tables as it contains only 2 columns values + rowid . Whereas tables contains 6 columns .
    <pre>
    Name      Datatype      Length      Mandatory      Comments
    ITEM_KEY      VARCHAR2      (240)      Yes      Unique identifier for the event raised
    PARAM_NAME      VARCHAR2      (2000)      Yes      Name of the parameter
    PARAM_CHAR      VARCHAR2      (4000)      
         Value of the parameter only if its data type is VARCHAR2.
    PARAM_NUM      NUMBER      
         Value of the parameter only if its data type is NUM.
    PARAM_DATE      DATE      
         Value of the parameter only if its data type is DATE.
    PARAM_INDICATOR      VARCHAR2      (3)      Yes      Indicates if the parameter contains existing, new or >replacement values. OLD values currently exist. NEW values create initial values or replace existing values.</pre>
    Regds
    Rahul

  • Defragmentation in 10g

    hi friends,
    Database: 10.2.0.3
    OS: windows 2003 server
    i had a tablespace (locally managed and segment space management auto) which is set as default for a user.
    few days back data was loaded into the tables for which i increased datafile size.
    yesterday, data is purged from the tables which are residing on this tablespace. because of this activity, fragmentation will occur in this tablespace.
    do we need to perform defragmentation on this tablespace (using expdp & impdp) to reclaim space? or in 10g is there any other way?
    thanks in advance.

    Oracle Devotee wrote:
    hi satish i do agree your point. but we require to reclaim the space to disk again. that space need to be used by archive destination. (we are having less disk space now)
    So, do you anticipate that this table (or any other object) will never again need that space? Not much point in jumping through all the hoops necessary to free it at the OS level, just to have to come back and re-allocate it next week.

  • Table fragmentation

    Hi all
    Please can one explain me which process is correct and less error free and less complecation to do a defragmentation
    1) take export of table and drop it and import it
    2) move table within the tablespcae
    3) take backup of table by select * from to backup table and truncate the main table and again insert the records from backup table to main table
    which is best and standerd approch
    Thanks

    Hi Arun,
    i recomend option 4, shrink:
    1) enable row movement
    ALTER TABLE scott.test ENABLE ROW MOVEMENT;
    2) move object rows and indexes (no lock)
    ALTER TABLE scott.test SHRINK SPACE CASCADE COMPACT;
    3) reset HMW (lock table!!!)
    ALTER TABLE scott.test SHRINK SPACE CASCADE;
    4)disable row movement
    ALTER TABLE scott.test DISABLE ROW MOVEMENT;
    with this you give free space to the tablespace.
    You can check reserved space, as you said "fragmentation":
    select table_name, NUM_ROWS,(blocks*8/1024)+ROUND((AVG_ROW_LEN * NUM_ROWS / (1024 * 1024)), 2) TOTAL, blocks*8/1024 Reserved_MB,  ROUND((AVG_ROW_LEN * NUM_ROWS / (1024 * 1024)), 2) Consumed_MB,
    ((blocks*8/1024)*100)/((blocks*8/1024)+ROUND((AVG_ROW_LEN * NUM_ROWS / (1024 * 1024)), 2)) RESERV
    from all_tables
    where OWNER like '[SCHEMA_NAME]'
    and NUM_ROWS > 1
    order by 4,6 desc;--sgc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get a list of most fragmented tables in Oracle?

    Is there an SQL on how to get a list of most fragmented tables in Oracle DBMS?

    Thanks! I would just like to ask you, what do the negative values mean in wasted space?
    Is there an easy way to improve defragmentation state?
    TABLE NAME     SIZE     ACTUAL DATA     WASTER SPACE
    TREE     0     0     0
    GC_S     3744     4651.9     -907.9
    TRAIL     104     113.04     -9.04
    ASSOCIATION_RULES     272     353     -81
    ATTRIBUTES     1728     2528.12     -800.12
    AUDITACTION     128     208.48     -80.48
    DV     18608     36266.47     -17658.47
    S134     728     903.08     -175.08
    A178     344     518.75     -174.75
    S129     728     896.48     -168.48
    AGS_NODES     2864     4510.33     -1646.33
    S149     472     633.79     -161.79
    S127     728     871.62     -143.62
    tu     2232     3619.76     -1387.76
    PCd_DATA     3112     4371.75     -1259.75

  • Defragmentation on system level

    Do as in the DB I have no defragmentation,
    So at the operating system will not have defragmentation?.
    Are the blocks in the extent always arranged in the same place the disk and in sequential order?
    Is when Oracle allocate new extents they always arranged in sequence on the disk (assuming the table is one file)?
    In eneral my question is
    when Oracle creates a file (DATA FILE) file is created in the same place on the disk?

    Sagi wrote:
    Do as in the DB I have no defragmentation,
    So at the operating system will not have defragmentation?.
    Are the blocks in the extent always arranged in the same place the disk and in sequential order?
    Is when Oracle allocate new extents they always arranged in sequence on the disk (assuming the table is one file)?
    In eneral my question is
    when Oracle creates a file (DATA FILE) file is created in the same place on the disk?You need to understand that Oracle is several layers of abstraction away from that spinning platter. In all but the most primitive of systems, even the OS is a few layers of abstraction away. At oracle's level .. even at the os level .. the concept of "contiguous" is really only "logically contiguous addresses" that have nothing at all* to do with the physical reality of read/write head position and cylinder/track/sector location on the disk.
    And don't forget that by the time the I/O request gets to the real physical level, it is done in terms of the sector on the platter, not the OS or database block. The sector size is determined by the hardware microcode, not the OS.
    Spend a few minutes thinking about the implications of that.
    Then throw in the complexity of a multi-user system, and the fact that once the disk and read/write head have completed an I/O operation on your behalf at their level, they will go service a request for some other user or process totally unrelated to your process.
    Edited by: EdStevens on Oct 16, 2010 10:28 AM

  • Unable to de-fragment a table index

    I have a table with a single PK index that shows a 75% fragmentation.
    I've tried rebuilding the index and I've tried reorganizing the index but neither changes the reported fragmentation for the table.
    I don't see any errors reported. I'm at a loss as to what I need to do to defragment this index.
    Any ideas what I'm doing wrong?
    BTW it's SQL 2008 R2 standard edition if that makes a difference.
    Developer Frog Haven Enterprises

    as Jason mentioned you should also consider index page count while defragmenting indexes,
    Generally, you should not be concerned with fragmentation levels of indexes with less than 1,000 pages. you can refer below article for more info
    Microsoft SQL Server Index Defragmentation Best Practices
    you can also refer Ola hallengren's index maintenance scripts.
    http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    Praveen Dsa | MCITP - Database Administrator 2008 |
    My Blog | My Page

  • Tablespace defragmentation for Oracle7

    Hi,
    I'm new at administration, and read about possibility of defragmenting the tablespaces of database, running on Oracle7. Could anyone tell me how to go about doing that?
    Also, the database is crawling slow lately, what obvious possibility should i look into?
    Advice and help needed urgently. Thank you.....
    Shannon

    tablespace defragmentation
    > export the objects that are in the tablespace(s)
    see export parameters: full, owner, tables
    > drop those objects
    side effects :( (for a table, its indexes will be dropped too)
    > defragment the tablespace(s)
    they must be empty at this point to be efficient
    > import the objects
    see import parameters: full, fromuser, touser, tables, commit
    example for the tablespaces: DATA, IDX
    The following lines have not been tested, so make them yours
    1. determine the schemas using those tablespaces
    SQL> select distinct owner from dba_segments where tablespace_name in ('DATA','IDX');
    SCHEMA1
    SCHEMA2
    2. those schemas must not use others tablespaces
    SQL> select distinct tablespace_name from dba_segments
    where tablespace_name not in ('DATA','IDX')
    and owner in ('SCHEMA1','SCHEMA2');
    no rows
    3. export the segments (tables, indexes, clusters) of each schemas
    os> exp userid=system/manager@ORCL owner=SCHEMA1 file=SCHEMA1.dmp
    os> exp userid=system/manager@ORCL owner=SCHEMA2 file=SCHEMA2.dmp
    (see the documentation for details on export parameters: compress, buffer,...)
    4. drop the segments
    SQL> connect SCHEMA1/SCHEMA1@ORCL
    SQL> spool drop_tables.sql
    SQL> select 'drop table '||table_name||' cascade constraints;' from user_tables;
    SQL> select 'drop cluster '||cluster_name||' including tables cascade constraints;' from user_clusters;
    SQL> @drop_tables.sql
    SQL> connect SCHEMA2/SCHEMA2@ORCL
    SQL> spool drop_tables.sql
    SQL> select 'drop table '||table_name||' cascade constraints;' from user_tables;
    SQL> select 'drop cluster '||cluster_name||' including tables cascade constraints;' from user_clusters;
    SQL> @drop_tables.sql
    5. each tablespace must be empty
    SQL> select * from dba_segments where tablespace_name in ('DATA','IDX');
    no rows
    6. defragment the tablespaces
    SQL> alter tablespace DATA coalesce;
    SQL> alter tablespace IDX coalesce;
    7. import the segments
    os> imp userid=system/manager@ORCL fromuser=SCHEMA1 touser=SCHEMA1 file=SCHEMA1.dmp
    os> imp userid=system/manager@ORCL fromuser=SCHEMA2 touser=SCHEMA2 file=SCHEMA2.dmp
    (see the documentation for details on import parameters: buffer, constraints,...)

Maybe you are looking for

  • Planning 9.3.1 - Date (data type)

    Hi, Has anyone used the feature Date data type for an account that is available in planning 9.3.1? I am trying to load and/or display it in the form and i keep getting invalid entry as an error even though i have made the account of Date data tpye an

  • Purchase Order  Held

    Dear Gurus Problem in Purchase Order In po screen ME23N at top of PO message is HELD PO Material Indian No.xxxxxx created by xxxxx Please let me know thw various prbabilities. ASAP Manoj

  • Cannot uninstall, repair, or reinstall Adobe Reader

    I think this suddenly happened a few days ago (no clue what the cause is), but since then no pdf files would have that pdf icon, they've all returned to the ugly "general file" icon, though it could still be opened with Adobe Reader. I have version 9

  • WCEM Used DCs are broken in the Track.

    WCEM 2.0 standard DCs are broken in my track. May I know if any one can give me the Dependencies list that are required for the SC in SLD and CMS?

  • IPad 2 - Only right headphone works.

    I Am now only getting sound through one of my earphones, and have tried many pairs! Can the earphone jack socket be replaced? My iPad is no longer under warranty, but would apple be able to fix this and how much would it cost? Cheers yo