How to find Table Fragmentation in Oracle Database

How to find Table Fragmentation in Oracle Database


What is Oracle Table Fragmentation?
If a table is only subject to inserts, there will not be any fragmentation.
Fragmentation comes with when we update/delete data in table.
The space which gets freed up during non-insert DML operations is not immediately re-used (or sometimes, may not get reuse ever at all). This leaves behind holes in table which results in table fragmentation.

To understand it more clearly, we need to be clear on how oracle manages space for tables.

When rows are not stored contiguously, or if rows are split onto more than one block, performance decreases because these rows require additional block accesses.

Note that table fragmentation is different from file fragmentation. When a lot of DML operations are applied on a table, the table will become fragmented because DML does not release free space from the table below the HWM.

HWM is an indicator of USED BLOCKS in the database. Blocks below the high water mark (used blocks) have at least once contained data. This data might have been deleted. Since Oracle knows that blocks beyond the high water mark don't have data, it only reads blocks up to the high water mark when doing a full table scan.

DDL statement always resets the HWM.

What are the reasons to reorganization of table?

a) Slower response time (from that table)
b) High number of chained (actually migrated) rows. 
c) Table has grown many folds and the old space is not getting reused.

Note: Index based queries may not get that much benefited by reorg as compared to queries which does Full table scan.

How to find Table Fragmentation?

In Oracle schema there are tables which has huge difference in actual size (size from User_segments) and expected size from user_tables (Num_rows*avg_row_length (in bytes)). This all is due to fragmentation in the table or stats for table are not updated into dba_tables.

Steps to Check and Remove Table Fragmentation:- 
=============================================
1. Gather table stats:
---------------------
To check exact difference in table actual size (dba_segments) and stats size (dba_tables). The difference between these value will report actual fragmentation to DBA. So, We have to have updated stats on the table stored in dba_tables. Check LAST_ANALYZED value for table in dba_tables. If this value is recent you can skip this step. Other wise i would suggest to gather table stats to get updated stats.

exec dbms_stats.gather_table_stats('&schema_name','&table_name');

2. Check Table size:
-------------------
Now again check table size using and will find reduced size of the table.

select table_name,bytes/(1024*1024*1024) from dba_table where table_name='&table_name';

3. Check for Fragmentation in table:
-----------------------------------
Below query will show the total size of table with fragmentation, expected without fragmentation and how much % of size we can reclaim after removing table fragmentation. Database Administrator has to provide table_name and schema_name as input to this query.

set pages 50000 lines 32767
select owner,table_name,round((blocks*8),2)||'kb' "Fragmented size", round((num_rows*avg_row_len/1024),2)||'kb' "Actual size", round((blocks*8),2)-round((num_rows*avg_row_len/1024),2)||'kb',
((round((blocks*8),2)-round((num_rows*avg_row_len/1024),2))/round((blocks*8),2))*100 -10 "reclaimable space % " from dba_tables where table_name ='&table_Name' AND OWNER LIKE '&schema_name'
/
Note: This query fetch data from dba_tables, so the accuracy of result depends on dba_table stats.

If you find reclaimable space % value more than 20% then we can expect fragmentation in the table. Suppose, DBA find 50% reclaimable space by above query, So he can proceed for removing fragmentation.

4. How to reset HWM / remove fragemenation?
---------------------------------------
We have four options to reorganize fragmented tables:

1. Alter table move (to another tablespace, or same tablespace) and rebuild indexes:- 
   (Depends upon the free space available in the tablespace) 
2. Export and import the table:- (difficult to implement in production environment)
3. Shrink command (fron Oracle 10g)
   (Shrink command is only applicable for tables which are tablespace with auto segment space management)

Here, I am following Options 1 and 3 option by keeping table availability in mind. 


Option: 1 Alter table move (to another tablespace, or same tablespace) and rebuild indexes:-
------------------------------------------------------------------------------------------
Collect status of all the indexes on the table:-
----------------------------------------------
We will record Index status at one place, So that we get back them after completion of this exercise,  

select index_name,status from dba_indexes where table_name like '&table_name';

Move table in to same or new tablespace:
---------------------------------------
In this step we will move fragmented table to same tablespace or from one tablespace to another tablespace to reclaim fragmented space. Find Current size of you table from dba_segments and check if same or any other tablespace has same free space available. So, that we can move this table to same or new tablespace.

Steps to Move table in to same tablespace:
-----------------------------------------
alter table <table_name> move;   ------> Move to same tablespace

OR

Steps to Move table in to new tablespace:
----------------------------------------
alter table <table_name> enable row movement;
alter table <table_name> move tablespace <new_tablespace_name>;

Now, get back table to old tablespaces using below command

alter table table_name move tablespace old_tablespace_name;

Now,Rebuild all indexes:
-----------------------
We need to rebuild all the indexes on the table because of move command all the index goes into unusable state.

SQL> select status,index_name from dba_indexes where table_name = '&table_name';

STATUS INDEX_NAME
-------- ------------------------------
UNUSABLE INDEX_NAME                            -------> Here, value in status field may be valid or unusable.

SQL> alter index <INDEX_NAME> rebuild online;  -------> Use this command for each index
Index altered.

SQL> select status,index_name from dba_indexes where table_name = '&table_name';

STATUS INDEX_NAME
-------- ------------------------------
VALID INDEX_NAME                               -------> Here, value in status field must be valid.

Gather table stats:
------------------
SQL> exec dbms_stats.gather_table_stats('&owner_name','&table_name');
PL/SQL procedure successfully completed.

Check Table size:
-----------------
Now again check table size using and will find reduced size of the table.

select table_name,bytes/(1024*1024*1024) from dba_table where table_name='&table_name';

Check for Fragmentation in table:
--------------------------------
set pages 50000 lines 32767
select owner,table_name,round((blocks*8),2)||'kb' "Fragmented size", round((num_rows*avg_row_len/1024),2)||'kb' "Actual size", round((blocks*8),2)-round((num_rows*avg_row_len/1024),2)||'kb',
((round((blocks*8),2)-round((num_rows*avg_row_len/1024),2))/round((blocks*8),2))*100 -10 "reclaimable space % " from dba_tables where table_name ='&table_Name' AND OWNER LIKE '&schema_name'
 /
==================================================================================================================
Option: 3 Shrink command (fron Oracle 10g):-
------------------------------------------

Shrink command: 
--------------
Its a new 10g feature to shrink (reorg) the tables (almost) online which can be used with automatic segment space management.

This command is only applicable for tables which are tablespace with auto segment space management.

Before using this command, you should have row movement enabled.

SQL> alter table <table_name> enable row movement;
Table altered.

There are 2 ways of using this command.

1. Rearrange rows and reset the HWM:
-----------------------------------
Part 1: Rearrange (All DML's can happen during this time)
SQL> alter table <table_name> shrink space compact;
Table altered.

Part 2: Reset HWM (No DML can happen. but this is fairly quick, infact goes unnoticed.)
SQL> alter table <table_name> shrink space;
Table altered.

2. Directly reset the HWM:
-------------------------
SQL> alter table <table_name> shrink space; (Both rearrange and restting HWM happens in one statement)
Table altered.

Advantages over the conventional methods are:
--------------------------------------------
1. Unlike "alter table move ..",indexes are not in UNUSABLE state.After shrink command,indexes are updated also.
2. Its an online operation, So you dont need downtime to do this reorg.
3. It doesnot require any extra space for the process to complete.


Credits : http://select-star-from.blogspot.in/2013/09/how-to-check-table-fragmentation-in.html

Intel I217LM ethernet controller not detected

Intel I217LM ethernet controller not detected

Solution

The Linux* e1000e driver supports PCI Express* Gigabit Network Connections except the 82575, 82576, 82580, and I350.

Download e1000e
Overview
Building and installation
For information concerning driver configuration details, refer to the Read Me file in the Download Center.


Overview

The Linux* base drivers support the 2.4.x and 2.6.x kernels. They include support for Itanium® 2-based systems.

The drivers are only supported as a loadable module. We don't supply patches against the kernel source to allow for static linking of the drivers. For questions related to hardware requirements, see the documentation supplied with your Intel® Gigabit Network Adapter. All hardware requirements listed apply for use with Linux.

Features now available in supported kernels:

Native VLANs
Channel Bonding (teaming)
SNMP
Find Channel Bonding documentation in the Linux kernel source: /documentation/networking/bonding.txt

This release doesn't support the driver information previously displayed in the /proc file system. You can also use ethtool (version 1.6 or later), lspci, and ifconfig to get the same information. Find instructions on updating ethtool in the additional configurations section.

Note The Intel® 82562v 10/100 Network Connection only provides 10/100 support.
back to top back to top

Building and installation

To build a binary RPM* package of this driver, run rpmbuild -tb e1000e.tar.gz.

Notes
For the build to work properly, the currently running kernel must match the version and configuration of the installed kernel sources. If you have just recompiled the kernel, reboot the system.

RPM functionality was only tested in Red Hat distributions.

Download current e1000e package from Download Center or SourceForge. Move the base driver tar file to the directory of your choice. For example, use "/home/<USERNAME>/e1000e" or "/usr/local/src/e1000e".

Untar/unzip the archive, where <x.x.x> is the version number for the driver tar file:

tar zxf e1000e-<x.x.x>.tar.gz
Change to the driver src directory, where <x.x.x> is the version number for the driver tar:

cd e1000e-<x.x.x>/src/
Compile the driver module:

# make install
The binary installs as:

/lib/modules/<KERNEL VERSION>/kernel/drivers/net/e1000e/e1000e.[k]o
The install location listed above is the default. Location may differ for various Linux distributions.

Load the module using either the insmod or modprobe command:

modprobe e1000e insmod e1000e
Note that you can use the insmod command for 2.6 kernels if you specify the full path to the driver module. For example:

insmod /lib/modules/<KERNEL VERSION>/kernel/drivers/net/e1000e/e1000e.ko
With 2.6 based kernels, make sure that older e1000e drivers are removed from the kernel before you load the new module:

rmmod e1000e; modprobe e1000e
Assign an IP address to the interface by entering the following, where <x> is the interface number:

ifconfig eth<x> <IP_address>
Verify that the interface works. Enter the following, where <IP_address> is the IP address for another machine on the same subnet as the interface you are testing:

ping <IP_address>

Note
Some systems have trouble supporting MSI and/or MSI-X interrupts. If your system must disable this style of interrupt, build and install the driver with the command:

# make CFLAGS_EXTRA=-DDISABLE_PCI_MSI install
Normally the driver generates an interrupt every two seconds If you're no longer seeing interrupts in cat /proc/interrupts for the ethX e1000e device, then this workaround may be necessary.

Reference :
Intel site

Your boot partition is on a disk using the GPT partitioning scheme but this machine cannot boot using GPT

Your boot partition is on a disk using the GPT partitioning scheme but this machine cannot boot using GPT

Following error after telling anaconda to install on pre-existing partitions (with GPT label):


On Partitioning screen, press Ctrl + Alt + F2 to get to a shell prompt.

$ parted /dev/sda -s mklabel msdos

Press Ctrl + Alt + F6 to return to the partitioning screen

SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

 

ISSUE: 


SQL> set autotrace traceonly;

SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

SP2-0611: Error enabling STATISTICS report


SOLUTION:


Users needs to have the PLUSTRACE role, which does not exist by default.

PLUSTRACE role can be created using SYS user by executing

ORACLE_HOME\sqlplus\admin\plustrce.sql 


The plustrace.sql creates the PLUSTRACE role

It also grants SELECT on V_$SESSTAT, V_$STATNME and V_$MYSTAT. 

PLUSTRACE is granted to the DBA role with ADMIN OPTION.


For 9i and earlier databases you may also need to create the plan table

by executing following script:-

$ORACLE_HOME\rdbms\admin\utlxplan.sql 


The PLAN_TABLE already exists on database version 10g and higher.


SQL> connect sys/sys as sysdba

Connected.


SQL> @%oracle_home%\sqlplus\admin\plustrce.sql;

SQL>

SQL> drop role plustrace;

drop role plustrace

          *

ERROR at line 1:

ORA-01919: role 'PLUSTRACE' does not exist


SQL> create role plustrace;

Role created.


SQL> grant select on v_$sesstat to plustrace;

Grant succeeded.


SQL> grant select on v_$statname to plustrace;

Grant succeeded.


SQL> grant select on v_$mystat to plustrace;

Grant succeeded.


SQL> grant plustrace to dba with admin option;

Grant succeeded.


After executing ORACLE_HOME\sqlplus\admin\plustrce.sql,

we need to grant PLUSTRACE role to the user.


SQL> grant plustrace to scott;

Grant succeeded.

SQL> connect scott/tiger

Connected.

SQL> set autotrace trace 

SQL> select user from dual; 

Execution Plan ----------------------------------------------------------

Plan hash value: 1388734953

----------------------------------------------------------------- 

| Id | Operation | Name | Rows | Cost (%CPU)| Time | 

-----------------------------------------------------------------

 | 0 | SELECT STATEMENT 

| | 1 | 2 (0)| 00:00:01 | | 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | 

-- Statistics --------- 1 recursive calls 0 db block gets 

0 consistent gets 0 physical reads 0 redo size 421 bytes 

sent via SQL*Net to client 415 bytes received via 

SQL*Net from client 2 SQL*Net roundtrips to/from 

client 0 sorts (memory) 0 sorts (disk) 1 rows processed


RC-20200: Fatal: Could not find Unzip. At this time only Native UnZip 5.X is supported.

RC-20200: Fatal: Could not find Unzip. At this time only Native UnZip 5.X is supported.

While cloning database Tier

Error :
RC-20200: Fatal: Could not find Unzip. At this time only Native UnZip 5.X is supported.

Please make sure you have UnZip 5.X in your path and try again…

 ERROR while running Apply…

 ERROR: Failed to execute /clone/oracle/product/11.2.0/appsutil/clone/bin/adclone.pl

  Please check logfile.

Solution 1

Which unzip should point to $ORACLE_HOME/bin/unzip

Take the backup of existing unzip from $ORACLE_HOME/bin

cd $ORACLE_HOME/bin

mv unzip unzip_bkp

cp /usr/bin/unzip to $ORACLE_HOME/bin

Make sure the unzip utility under /usr/bin should be of version 5.X and not 6

Solution 2

As root user, rename the default unzip (/usr/bin/unzip) to a temporary filename (e.g. /usr/bin/unzip-ver6), perform the task, and then rename unzip-ver6 to the original name when completed.

# mv /usr/bin/unzip /usr/bin/unzip-ver6

Solution 3

unzip utility
https://oss.oracle.com/el4/unzip/unzip.html