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
Similar Messages
-
Finding table fragmentation in Oracle 8.1.6.3.0
Hi All,
I just want to find table fragmentation for one table named LOG. I used below query to find this....
SQL> select table_name,round((blocks*8),2)||'kb' "size"
from dba_tables
where table_name = 'LOG' and owner='AMRWF1'; 2 3
TABLE_NAME size
LOG 6301408kb
SQL> select table_name,round((num_rows*avg_row_len/1024),2)||'kb' "size"
from dba_tables
where table_name = 'LOG' and owner='AMRWF1'; 2 3
TABLE_NAME size
LOG 1468846.2kbAnd tablespace infromation is below.
SQL> select bytes/1024/1024,TABLESPACE_NAME,EXTENTS,MAX_EXTENTS from dba_segments where owner='AMRWF1' and segment_name='LOG';
BYTES/1024/1024 TABLESPACE_NAME EXTENTS MAX_EXTENTS
6154.16406 WFMKTLEAST 12214 2147483645
SQL> sho parameter block
NAME TYPE VALUE
db_block_buffers integer 100000
db_block_checking boolean FALSE
db_block_checksum boolean FALSE
db_block_lru_latches integer 3
db_block_max_dirty_target integer 100000
db_block_size integer 8192
db_file_multiblock_read_count integer 8
hash_multiblock_io_count integer 0
sort_multiblock_read_count integer 2Please mention whether i am fallowing proper method to find table fragmentation and this table is severly fragmented or not???
-Yasser
Edited by: YasserRACDBA on May 12, 2009 7:17 PMSir Please refer below statspack report
STATSPACK report for
Snap Length
Start Id End Id Start Time End Time (Minutes)
201 213 13-May-09 01:32:02 13-May-09 01:51:30 19.47
Cache Sizes
~~~~~~~~~~~
db_block_buffers: 100000
db_block_size: 8192
log_buffer: 2097152
shared_pool_size: 132003840
Load Profile
~~~~~~~~~~~~
Per Second Per Transaction
Redo size: 186,962.61 2,244.02
Logical reads: 18,690.20 224.33
Block changes: 835.84 10.03
Physical reads: 1,422.98 17.08
Physical writes: 59.20 0.71
User calls: 693.17 8.32
Parses: 219.19 2.63
Hard parses: 95.50 1.15
Sorts: 122.47 1.47
Transactions: 83.32
Rows per Sort: 13.87
Pct Blocks changed / Read: 4.47
Recursive Call Pct: 57.35
Rollback / transaction Pct: 0.01
Instance Efficiency Percentages (Target 100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Buffer Nowait Ratio: 99.82
Buffer Hit Ratio: 92.39
Library Hit Ratio: 85.79
Redo NoWait Ratio: 99.99
In-memory Sort Ratio: 100.00
Soft Parse Ratio: 56.43
Latch Hit Ratio: 99.55
Top 5 Wait Events
~~~~~~~~~~~~~~~~~ Wait % Total
Event Waits Time (cs) Wt Time
log file sync 98,328 308,489 52.94
db file sequential read 1,462,138 135,491 23.25
buffer busy waits 40,122 41,574 7.13
log file parallel write 67,541 29,561 5.07
latch free 14,153 29,250 5.02
^LWait Events for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
->cs - centisecond - 100th of a second
->ms - millisecond - 1000th of a second (unit often used for disk IO timings)
Avg
Total Wait wait Waits
Event Waits Timeouts Time (cs) (ms) /txn
log file sync 98,328 4 308,489 31 1.0
db file sequential read 1,462,138 0 135,491 1 15.0
buffer busy waits 40,122 1 41,574 10 0.4
log file parallel write 67,541 8 29,561 4 0.7
latch free 14,153 10,702 29,250 21 0.1
db file parallel write 5,099 0 18,117 36 0.1
db file scattered read 18,561 0 9,258 5 0.2
db file parallel read 3,227 0 5,658 18 0.0
SQL*Net more data to client 44,457 0 1,188 0 0.5
log file sequential read 8,020 0 1,070 1 0.1
direct path write 410 0 669 16 0.0
direct path read 688 0 556 8 0.0
control file parallel write 444 0 533 12 0.0
library cache pin 517 0 461 9 0.0
LGWR wait for redo copy 798 143 414 5 0.0
log file switch completion 30 0 349 116 0.0
single-task message 4 0 27 68 0.0
file open 959 0 23 0 0.0
log file single write 20 0 7 4 0.0
control file sequential read 458 0 4 0 0.0
refresh controlfile command 36 0 3 1 0.0
enqueue 9 0 2 2 0.0
file identify 40 0 1 0 0.0
SQL*Net break/reset to clien 4 0 0 0 0.0
buffer deadlock 2 2 0 0 0.0
SQL*Net message from client 809,303 0 19,936,895 246 8.3
virtual circuit status 38 38 116,785 ##### 0.0
SQL*Net message to client 809,327 0 310 0 8.3
SQL*Net more data from clien 477 0 43 1 0.0
^LSQL ordered by Gets for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
Gets % of
Buffer Gets Executes per Exec Total Hash Value
SQL statement
262,083 159,120 1.6 1.2 382965845
SELECT GEOPAR,NAME FROM GEO WHERE GEOCOD = RTRIM(:b1)
146,040 1 146,040.0 .7 1754824507
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09120A
141,075 1 141,075.0 .6 1542925332
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09120A
128,943 12,612 10.2 .6 4085293067
UPDATE OBJECT SET OWNER = NULL, LOCKTIME = 0, QUEUE_TIMESTAMP = NULL WHERE "ID
91,085 1 91,085.0 .4 323282248
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09126A
90,887 1 90,887.0 .4 2613220927
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09126A
66,045 9,174 7.2 .3 3352553713
SELECT DOC_NUM,TITLE,AUTHOR,C.TYPE,DATE_RPT,S.COLLECTION,S.AUTOMATION,LANG,SOU
61,337 9,498 6.5 .3 2345958421
SELECT PAGENO PAGENO FROM NONBILL WHERE REPORTID = :b1
59,669 9,500 6.3 .3 4181220996
SELECT RTRIM(SUBCOLLECT) SUBCOLLECT_CODE FROM MARK_SUBCOLLECT WHERE SRCCOD
54,543 1 54,543.0 .2 2236963897
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,517 1 54,517.0 .2 2215353317
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,493 1 54,493.0 .2 1430216754
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,450 1 54,450.0 .2 3671439846
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,443 1 54,443.0 .2 4024618165
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,404 1 54,404.0 .2 4144413353
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,185 1 54,185.0 .2 3853441439
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
54,122 1 54,122.0 .2 4066390851
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09128A
^LSQL ordered by Reads for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
Physical Reads % of
Reads Executes per Exec Total Hash Value
SQL statement
52,578 1 52,578.0 3.2 1754824507
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09120A
31,998 1 31,998.0 1.9 2613220927
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09126A
16,013 1 16,013.0 1.0 323282248
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09126A
10,819 1 10,819.0 .7 1542925332
SELECT ERROR,TIME_STAMP,O_RESOURCE,QUEUE,NEW_QUEUE FROM LOG WHERE ID = '09120A
5,940 9,500 0.6 .4 1788460650
SELECT RTRIM(SUBJCT) TICKER,RTRIM(NAME) NAME,RTRIM(STATE) STATE,RTRIM(COUNTRY)
5,011 5 1,002.2 .3 1283665788
INSERT INTO STATS$SQL_SUMMARY ( SNAP_ID,DBID,INSTANCE_NUMBER,SQL_TEXT,SHARABLE
3,532 104 34.0 .2 2416764375
INSERT INTO DOC_SUBJCT ( DOC_NUM,TYPE,SUBJCT ) VALUES ( TO_NUMBER(:b1),:b2,:b
3,178 3 1,059.3 .2 2869630514
BEGIN statspack.snap(i_snap_level => 10, i_modify_parameter => 'true'); END;
1,576 9,174 0.2 .1 3352553713
SELECT DOC_NUM,TITLE,AUTHOR,C.TYPE,DATE_RPT,S.COLLECTION,S.AUTOMATION,LANG,SOU
816 1,753 0.5 .0 2074917603
INSERT INTO LOG (ID,TIME_STAMP,TYPE,ERROR,INSTANCE,RULE_NUM,RULE_TYPE,PRIORITY
754 324 2.3 .0 4111801531
begin packager.get_citation(:param1 , :out); end;
567 83 6.8 .0 924335069
INSERT INTO CORDOC ( DOC_NUM,PARENT_DOC,SOURCE,AUTHOR,TITLE,DATE_RPT,DATE_RCVD
441 9,500 0.0 .0 2184883084
SELECT TPCCOD,TPCNAM FROM TOPICS T,DOC_SUBJCT D WHERE D.DOC_NUM = :b1 AND
430 104 4.1 .0 2993182807
INSERT INTO DOC_SUBJCT_UPD_LOG ( DOC_NUM,TYPE,SUBJCT,TYPE_OF_CHANGE,CREATED_LO
406 9,498 0.0 .0 2345958421
SELECT PAGENO PAGENO FROM NONBILL WHERE REPORTID = :b1
304 414 0.7 .0 199702406
select i.obj#,i.ts#,i.file#,i.block#,i.intcols,i.type#,i.flags, i.property,i.p
300 7,733 0.0 .0 3207681720
SELECT NVL(IMAGES,0) IMAGES,NVL(NONBILLABLE,0) NONBILLABLE FROM IMAGED_DOCUM
^LSQL ordered by Rows for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
Rows Rows
Processed Executes per Exec Hash Value
SQL statement
87,357 159,120 0.5 382965845
SELECT GEOPAR,NAME FROM GEO WHERE GEOCOD = RTRIM(:b1)
32,818 9,498 3.5 2345958421
SELECT PAGENO PAGENO FROM NONBILL WHERE REPORTID = :b1
12,612 12,612 1.0 4085293067
UPDATE OBJECT SET OWNER = NULL, LOCKTIME = 0, QUEUE_TIMESTAMP = NULL WHERE "ID
9,544 9,544 1.0 1230017382
SELECT LOG_SEQUENCE.NEXTVAL FROM DUAL
9,498 9,498 1.0 2684256693
SELECT RTRIM(NAME) NAME FROM LANG WHERE LANG.CODE = :b1
9,174 9,174 1.0 3352553713
SELECT DOC_NUM,TITLE,AUTHOR,C.TYPE,DATE_RPT,S.COLLECTION,S.AUTOMATION,LANG,SOU
7,575 7,733 1.0 3207681720
SELECT NVL(IMAGES,0) IMAGES,NVL(NONBILLABLE,0) NONBILLABLE FROM IMAGED_DOCUM
7,526 9,500 0.8 1788460650
SELECT RTRIM(SUBJCT) TICKER,RTRIM(NAME) NAME,RTRIM(STATE) STATE,RTRIM(COUNTRY)
6,485 514 12.6 395844583
select name,intcol#,segcol#,type#,length,nvl(precision#,0),decode(type#,2,nvl(
3,308 9,499 0.3 3612837332
SELECT RTRIM(D.SUBJCT) INDCOD,RTRIM(INDNAM) INDNAM,NIC_COD_BEST FROM DOC_SUB
2,642 9,500 0.3 4181220996
SELECT RTRIM(SUBCOLLECT) SUBCOLLECT_CODE FROM MARK_SUBCOLLECT WHERE SRCCOD
1,753 1,753 1.0 2074917603
INSERT INTO LOG (ID,TIME_STAMP,TYPE,ERROR,INSTANCE,RULE_NUM,RULE_TYPE,PRIORITY
1,380 1,855 0.7 1867085649
INSERT INTO LOG (ID,TIME_STAMP,TYPE,ERROR,INSTANCE,RULE_NUM,RULE_TYPE,PRIORITY
1,347 359 3.8 1536916657
select con#,type#,condlength,intcols,robj#,rcon#,match#,refact,nvl(enabled,0),
870 104 8.4 2416764375
INSERT INTO DOC_SUBJCT ( DOC_NUM,TYPE,SUBJCT ) VALUES ( TO_NUMBER(:b1),:b2,:b
828 433 1.9 1943674664
SELECT CLASS, PRIVILEGE FROM PRIVILEGE WHERE GROUP_NAME = 'SYSADMIN'
723 433 1.7 2958422142
SELECT CLASS, PRIVILEGE FROM PRIVILEGE WHERE GROUP_NAME = 'DEFAULT'
^LLatch Activity for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
->"Pct Misses" should be very close to 0.0
Pct Avg Pct
Get Get Sleeps Nowait Nowait
Latch Name Requests Miss /Miss Requests Miss
Active checkpoint queue latch 82,223 0.0 0
Checkpoint queue latch 828,701 0.0 0.0 0
Token Manager 739 0.0 5,586 0.0
archive control 10 0.0 0
archive process latch 10 0.0 0
cache buffer handles 8,728 0.0 0
cache buffers chains 45,374,520 0.0 0.1 1,915,719 0.2
cache buffers lru chain 293,252 0.5 0.1 1,667,702 0.6
channel handle pool latch 293 0.0 294 0.0
channel operations parent latch 586 0.0 294 0.0
dml lock allocation 197,311 0.0 0.0 0
enqueue hash chains 438,592 0.1 0.1 0
enqueues 697,793 0.1 0.0 0
event group latch 293 0.0 0
job_queue_processes parameter l 65 0.0 0
ktm global data 4 0.0 0
latch wait list 6,541 2.5 0.0 6,559 0.2
library cache 6,095,682 0.9 0.2 186,918 0.8
library cache load lock 4,494 0.0 0
list of block allocation 201,252 0.0 0.1 0
loader state object freelist 46 0.0 0
longop free list 1,508 0.0 0
messages 925,509 0.2 0.0 0
multiblock read objects 45,236 0.0 4.6 3 0.0
ncodef allocation latch 65 0.0 0
process allocation 293 0.0 293 0.0
process group creation 587 0.0 0
redo allocation 624,066 0.1 0.0 0
redo writing 511,337 0.8 0.0 0
row cache objects 9,553,633 1.0 0.0 13,023 3.7
sequence cache 31,263 0.0 0.0 0
session allocation 454,171 0.3 0.0 0
session idle bit 1,841,211 0.0 0.1 0
session switching 65 0.0 0
session timer 416 0.0 0
shared pool 4,602,509 3.3 0.0 0
sort extent pool 78 0.0 0
transaction allocation 295,180 0.0 0.0 0
transaction branch allocation 65 0.0 0
undo global data 346,591 0.1 0.2 0
user lock 2,114 0.0 0
virtual circuit queues 56 0.0 0
^LLatch Sleep breakdown for DB: PRDTDB Instance: prdtdb Snaps: 201 - 21
Get Spin &
Latch Name Requests Misses Sleeps Sleeps 1-4
shared pool 4,602,509 152,786 3,804 150445/1393/
698/250/0
row cache objects 9,553,633 98,968 364 98730/210/3/
25/0
library cache 6,095,682 53,621 8,107 49775/1473/1
726/647/0
cache buffers chains 45,374,520 10,906 1,415 10308/336/71
/191/0
redo writing 511,337 3,927 39 3892/31/4/0/
0
messages 925,509 1,443 61 1382/61/0/0/
0
cache buffers lru chain 293,252 1,388 130 1260/127/0/1
/0
session allocation 454,171 1,334 15 1319/15/0/0/
0
enqueues 697,793 1,000 11 989/11/0/0/0
redo allocation 624,066 623 5 618/5/0/0/0
session idle bit 1,841,211 447 50 400/46/0/1/0
Checkpoint queue latch 828,701 378 8 374/3/0/1/0
undo global data 346,591 330 62 315/4/1/10/0
enqueue hash chains 438,592 273 32 259/7/2/5/0
transaction allocation 295,180 138 5 133/5/0/0/0
dml lock allocation 197,311 46 2 44/2/0/0/0
list of block allocation 201,252 40 4 36/4/0/0/0
multiblock read objects 45,236 7 32 2/1/1/3/0
^LLatch Miss Sources for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
No Wait
Latch Name Where Misses Sleeps
Checkpoint queue latch kcbswcu: Switch buffers 0 5
Checkpoint queue latch kcbk0rrd: update recovery 0 2
Checkpoint queue latch kcbbcthc: check thread que 0 1
cache buffers chains kcbrls: kslbegin 0 724
cache buffers chains kcbgtcr: kslbegin 0 533
cache buffers chains kcbgcur: kslbegin 0 62
cache buffers chains kcbchg: kslbegin: call CR 0 29
cache buffers chains kcbzgb: scan from tail. no 0 25
cache buffers chains kcbzib: multi-block read: 0 14
cache buffers chains kcbzib: finish free bufs 0 9
cache buffers chains kcbzwb 0 8
cache buffers chains kcbchg: kslbegin: bufs not 0 6
cache buffers chains kcbget: pin buffer 0 3
cache buffers chains kcbget: exchange rls 0 1
cache buffers lru chain kcbbiop: lru scan 0 105
cache buffers lru chain kcbzgb: multiple sets nowa 0 21
cache buffers lru chain kcbzgb: posted for free bu 0 3
cache buffers lru chain kcbbwlru 0 1
dml lock allocation ktaiam 0 2
enqueue hash chains ksqgtl3 0 16
enqueue hash chains ksqrcl 0 16
enqueues ksqgtl2 0 5
enqueues ksqies 0 4
enqueues ksqrcl 0 2
library cache kgllkdl: child: cleanup 0 895
library cache kglpnal: child: alloc spac 0 711
library cache kglic 0 344
library cache kglupc: child 0 261
library cache kglhdgn: child: 0 227
library cache kglpnal: child: before pro 0 116
library cache kglhdgc: child: 0 82
library cache kglobpn: child: 0 74
library cache kgldnp: child 0 57
library cache kglsca: parent 0 57
library cache kgllkdl: child: free pin 0 29
library cache kglati 0 27
library cache kglpnc: child 0 15
library cache kgldte: child 0 0 8
library cache kglget: child: KGLDSBYD 0 3
library cache kglobld: child: 0 2
library cache kglpin 0 2
library cache kgldti: not under latch 0 1
library cache kglpnp: child 0 1
list of block allocation ktlbbl 0 4
messages ksaamb: after wakeup 0 40
messages ksarcv: after wait 0 13
messages ksarcv 0 8
multiblock read objects kcbzib: MBRGET 0 32
redo allocation kcrfwr: redo allocation 0 4
redo allocation kcrfwi: before write 0 1
redo writing kcrfss 0 17
redo writing kcrfsr 0 16
redo writing kcrfwi: after write 0 5
redo writing kcrfwcr 0 1
row cache objects kqrpre: find obj 0 190
^LLatch Miss Sources for DB: PRDTDB Instance: prdtdb Snaps: 201 - 213
No Wait
Latch Name Where Misses Sleeps
row cache objects kqreqd: rel enqueue 0 93
row cache objects kqreqd 0 64
row cache objects kqrso 0 1
session allocation ksuxds: not user session 0 12
session allocation ksucri 0 2
session allocation ksuxds: KSUSFCLC not set 0 1
session idle bit ksuxds 0 22
session idle bit ksupuc: clear busy 0 17
session idle bit ksupuc: set busy 0 11
shared pool kghfrunp: parent clatch: w 0 5,059
shared pool kghfrunp: alloc: wait 0 1,296
shared pool kghfrunp: alloc: clatch no 0 1,152
shared pool kghalo 0 852
shared pool kghfnd: min scan 0 180
shared pool kghfrunp: clatch: wait 0 112
shared pool kghupr1 0 104
shared pool kghfnd: get next extent 0 72
shared pool kghfnd: req scan 0 55
shared pool kghfre 0 40
shared pool kghalp 0 31
shared pool kghfrunp: clatch: nowait 0 30
shared pool kghfen: not perm alloc cla 0 15
shared pool kghfrunp: no latch 0 2
shared pool kghfrunp: reget min scan 0 1
transaction allocation ktcdso 0 3
transaction allocation ktcxba 0 2
undo global data ktudba: KSLBEGIN 0 61
undo global data ktudnx: KSLBEGIN 0 1
End of ReportPlease find partial output of v$sql;
EXECUTIONS DISK_READS BUFFER_GETS ROWS_PROCESSED
11170 0 0 0
11726 6206 36460 11286
11727 3079 193977 11727
12007 278 69951 39346
12700 0 31165 43631
13371 564 26871 7113
15568 0 1045 0
16122 28 25925 8603
16583 292 10230 2016
16943 31 1092 209
17933 896 35957 17933
EXECUTIONS DISK_READS BUFFER_GETS ROWS_PROCESSED
17958 0 3675 0
22750 6968 132458 32748
22840 518 31455 43631
22840 1 37398 0
22976 109 46286 22966
23002 53 23280 22975
23002 16 23216 23002
23003 61 23362 23003
23005 764 78363 23003
25580 1303 81762 373057
27092 0 0 0
EXECUTIONS DISK_READS BUFFER_GETS ROWS_PROCESSED
29218 1069 88739 29218
32750 3 1020 355
35790 453 279237 27807
38630 488 116142 1331
42128 13 2679 180
45899 0 229499 45896
45984 87 230393 45984
50588 3 1931 145
51215 81 256945 51215
52212 9 2248 674
62501 2 2087 506
EXECUTIONS DISK_READS BUFFER_GETS ROWS_PROCESSED
75230 1393 950678 71295
95712 29410 1451214 87782
102950 5250 1694896 102950
165722 254 870666 165722
527966 790 2773361 527965
674310 190 5482921 674307
709403 1198 3727110 709403
1093841 2338 11416812 1093840Btree index type has been created.
Please guide me in finding CPU problem.
-Yasser -
Is my table fragmented ?
Hi,
Trying to find out whether table is fragmented or not ?
select segment_name,sum(bytes)/1024/1024 from dba_extents where owner='UAT_LIVE1' group by segment_name order by 2 desc
Size:- 524 MB
select segment_name,segment_type,tablespace_name,sum(bytes)/1024/1024 from dba_segments where segment_type='TABLE' and owner='UAT_LIVE1' group by segment_name,segment_type,tablespace_name order by 4 desc
Size:- 524 MB
select * from dba_tables where table_name='OTP_PR_TRAVELLER' and owner='UAT_LIVE1'
Size:- 455 MB
Can anybody tell me - is my table fragmented , If yes, then how to defrag it ?Are you using automatic segment space management (ASSM)?
Almost everything is going to depend on how your table is set up and how it is used in practice. Optmal storage allocation is all about matching those two things.
What are the PCTFREE and PCTUSED settings on the table (if you aren't familiar with those settings, I'd strongly suggest reading the Concepts guide section on database blocks for background)? Can you describe the life cycle of a row? Do you ever do updates? Do those updates ever increase the size of a variable length column? Do you ever do deletes?
In general, the default settings are going to be pretty good for most tables in most applications. While a human being might be able to do a better job on some tables, there is a lot to be said for accepting the default, getting a very good but not quite optimal result, and focusing scarce human attention on things that are likely to have a much bigger return. Just because something can be made more optimal doesn't, by any stretch, mean that the cost of making the improvement is worth the effort.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Added last paragraph on costs & benefits.
Message was edited by:
Justin Cave -
How i know what one table is fragmented ??
Tks ..
Samuel
Brazilrajeysh wrote:
refer the link;
http://www.orafaq.com/node/1936
Good points about the link:
<ul>
it tells you that you have four options
it gives you one idea of how to check for possible "empty" space below the HWM
</ul>
Bad points about the link:
<ul>
it doesn't tell you anything about the nasty side-effects of the methods
it doesn't give you any information about the pros and cons of each method
the first three paragraphs are misleding
</ui>
<blockquote>
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.
</blockquote>
para1: what is a "non-contiguous row" ? - the opening phrase needs explanation
para1: "if rows are split onto more than one block" - doesn't distinguish between migrated and chained rows
para2: <i>"DML does not release ..."</i> - of course it does, it's just a question of when. This remark should not be made without a proper explanation
para3: minor quibble - the article was written in 2007, and ASSM has been around a lot longer - there could be a significant number of blocks below the HWM which have not yet been formatted.
Conclusion: Article not suitable reference material.
Regards
Jonathan Lewis -
Reg : Table Fragmentation
Hi Basis Guru's
What is meant by Table Fragmentation?Plz help with steps..Hello,
Table Fragmentation
Table fragmentation is the inability of the system to lay out related data sequentially (contiguously), an inherent phenomenon in storage-backed file systems that allow in-place modification of their contents.
The correction to existing fragmentation is to compress tables and free space back into contiguous areas, a process called defragmentation.
Table fragmentation will result in longer query times when a full table scan is performed. Since data is not as evenly packed in the data blocks, many blocks may have to be read during a scan to satisfy the query. These blocks may be distributed on various extents. In this case, Oracle must issue recursive calls to locate the address of the next extent in the table to scan.
Recent studies have shown that table fragmentation has hardly any effect on the performance of the database system. This is mainly because full table scans are somewhat rare in an SAP system since data is accessed using an index.
REWARD POINTS IF HELPFUL
Regards
Sai -
Best Practices - Removing table fragmentations.
What is the best practices for removing the fragmentation in the tables. Does this process be used after every week month or every day.
Hi Chunm,
What is the best practices for removing the fragmentation in the tables.I monitor chained rows (table fetch continued rows), reorg with dbms_redefinition (or move to larger blocksize), and ALWAYS adjust PCTFREE to prevent future fragmentation. Read this:
http://www.dba-oracle.com/t_identify_chained_rows.htm
http://www.dba-oracle.com/oracle_tips_fetch_cont_rws.htm
Hope this helps. . .
Don Burleson
Oracle Press author -
Performance degradation due to table fragmentation
Dear all,
We use a table in oracle to store session IDs for various web applications. This is a very busy table because several rows are inserted and updated almost every single second by web-applications. Due to this reason the disk space containing this table gets apparently gets fragmented and results in poor performance of our web applications. Whenever this table is freshly re-built, the performance of our web application returns back to it’s normal level.
Can someone kindly advice if this is a normal behaviour of Highly fragmented tables using ASM (Automatic storage Management) ? should the performance of applications degrade if tables are fragmented ? Also are there any suggestions if there is any better solution rather than re-building the table every month ?
We use Oracle 10.1.0.4 using Real Application Clusters. Our storage system is based on Automatic storage Management (ASM).
Thanks and regardsThanks for the Reply.
No there is no union let take an example
There is a table Bank this will be owned by ad1 and we created a synonym in ap1 with the same name bank but only granting the dml access to ap1.
Second thing we created the new users , For that also do we need to gather statistics -
How can i know the table fragments
Hi
How can i know the table is fragmented.
Thank youIf you're in 10g you could try use the Segment Advisor to identify various issues etc with your table. This will also provide recommendations on how to improve things.
(below script shamelessly stolen from the brilliant Oracle Base website)
-- segment_adv_table.sql
-- Use Segment Advisor to analyse a table.
-- Original Version
-- http://www.oracle-base.com/articles/10g/SpaceObjectTransactionManagement10g.php
-- owner is SCOTT
-- table is EMP
-- do a search/replace to change these 2 values and re-run it ;)
DECLARE
l_object_id NUMBER;
BEGIN
-- Create a segment advisor task for the SCOTT.EMP table.
DBMS_ADVISOR.create_task (
advisor_name => 'Segment Advisor',
task_name => 'EMP_SEGMENT_ADVISOR',
task_desc => 'Segment Advisor For EMP');
DBMS_ADVISOR.create_object (
task_name => 'EMP_SEGMENT_ADVISOR',
object_type => 'TABLE',
attr1 => 'SCOTT',
attr2 => 'EMP',
attr3 => NULL,
attr4 => 'null',
attr5 => NULL,
object_id => l_object_id);
DBMS_ADVISOR.set_task_parameter (
task_name => 'EMP_SEGMENT_ADVISOR',
parameter => 'RECOMMEND_ALL',
value => 'TRUE');
DBMS_ADVISOR.execute_task(task_name => 'EMP_SEGMENT_ADVISOR');
END;
-- Display the findings.
SET LINESIZE 250
COLUMN task_name FORMAT A20
COLUMN object_type FORMAT A20
COLUMN schema FORMAT A20
COLUMN object_name FORMAT A30
COLUMN object_name FORMAT A30
COLUMN message FORMAT A40
COLUMN more_info FORMAT A40
SELECT f.task_name,
f.impact,
o.type AS object_type,
o.attr1 AS schema,
o.attr2 AS object_name,
f.message,
f.more_info
FROM dba_advisor_findings f
JOIN dba_advisor_objects o ON f.object_id = o.object_id AND f.task_name = o.task_name
WHERE f.task_name IN ('EMP_SEGMENT_ADVISOR', 'USERS_SEGMENT_ADVISOR')
ORDER BY f.task_name, f.impact DESC; -
Table Fragmentation and claim tablesapce
The following scripts are checking Tablespace and Fragmentation:
select
total.file_name fname,
total.bytes/1024 totsiz,
nvl(sum(free.bytes)/1024,0) avasiz,
(1-nvl(sum(free.bytes),0)/total.bytes)*100 pctusd
from
dba_data_files total,
dba_free_space free
where
total.tablespace_name = 'APPLSYSD'
and total.tablespace_name = free.tablespace_name(+)
and total.file_id=free.file_id(+)
group by
total.tablespace_name,
total.file_name,
total.bytes
The followings are the result:
TSNAME NFRAGS MXFRAG TOTSIZ AVASIZ PCTUSD
===============================================
AKD 2 45600 358400 45680 87.25446429
AKX 1 37360 256000 37360 85.40625
APD 2 30680 512000 30720 94
APX 1 23880 460800 23880 94.81770833
ARD 1 6120 204800 6120 97.01171875
ARX 1 73360 409600 73360 82.08984375
AXD 1 159520 204800 159520 22.109375
AXX 3 13880 102400 13960 86.3671875
AZD 1 9040 10240 9040 11.71875
From the above result, which one has serious fragmentation so that I can resize datafile in order to reclaim space from "APPSYSD"?
Please advice,
Amyexecute the below query and post the result.
col tablespace_name for a25
col file_name for a60
set pages 150
set lines 150
select df.tablespace_name ,
df.file_name ,
df.file_id ,
df.totalspace,
fs.freespace from
(select
tablespace_name,
file_name,
file_id,
round(sum(bytes)/1024/1024,2) as totalspace
from dba_data_files
group by tablespace_name,file_name,file_id) df,
(select
tablespace_name,
file_id,
round(sum(bytes)/1024/1024,2) as freespace
from dba_free_space
group by tablespace_name,file_id) fs
where df.file_id=fs.file_id (+)
order by 5 desc
Regards
RajaBaskar -
How to Decrease fragmentation level of a table.
Hello Everyone,
There is a table present in my production database.
Its version is Oracle 10G(10.2.0.1.0)
i)Its size is 26 GB with fragmentation level.
ii)It has more then 48 crores of rows.
iii)Its size is 20 GB without fragmentation level.(So 6 GB of unused space is wasted).
Following are my doubts regarding the above points.
i) How to decrease the fragmentation level of the table.
ii) if there is any way to decrease the fragmentation level,how much time it will take to perform the particular activity so as to decrease the fragmentation level.Well Mine is Oracle 10G. Hence the production database is Locally Managed.Well it has more then 48 millions of rows in my table
Definition of Fragmentation :-
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.
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.
Definition of High Water Mark(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.
Please go through the below example if you have any doubts.
EXAMPLE:-
How to find table fragmentation?
SQL> select count(*) from big1;
1000000 rows selected.
SQL> delete from big1 where rownum <= 300000;
300000 rows deleted.
SQL> commit;
Commit complete.
SQL> update big1 set object_id = 0 where rownum <=350000;
342226 rows updated.
SQL> commit;
Commit complete.
SQL> exec dbms_stats.gather_table_stats('SCOTT','BIG1');
PL/SQL procedure successfully completed.
Now lets determine the size of table
TABLE SIZE(with fragmentation)
SQL> select table_name,round((blocks*8),2)||'kb' "size"
2 from user_tables
3 where table_name = 'BIG1';
TABLE_NAME size
BIG1 72952kb
ACTUAL DATA in table:
SQL> select table_name,round((num_rows*avg_row_len/1024),2)||'kb' "size"
2 from user_tables
3 where table_name = 'BIG1';
TABLE_NAME size
BIG1 30604.2kb
Note = 72952 - 30604 = 42348 Kb is wasted space in table
Edited by: 855956 on May 3, 2011 12:11 PM -
Hello,
Can someone give me the sql to determine what tables and or tablespaces are say 15% fragmented? I'm on Oracle 9i.
thanks...Are you using locally managed tablespaces? If so, you can stop worrying about tablespace fragmentation, particularly if you are using UNIFORM extents.
Can you define "table fragmentation"? I'm hard-pressed to figure out how a table can be fragmented.
Assuming you need to worry about fragmentation in the first place, either because you are still using dictionary managed tablespaces or because you have "table fragmentation" for some definition of the term, can you define what you mean by percentage fragmentation? If you have a dictionary managed tablespace, it is not obvious what it would mean to have a tablespace that was 15% fragmented.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
What is the difference between Table & Tablespace Fragmentation
What is the difference between Table Fragmentation & Tablespace Fragmentation.
What causes Table Fragmentation and what cause Tablespace Fragmentation.
How can we avoid Table Fragmentation & Tablespace Fragmentation.
How can we fix already Fragmented Tables & Fragmented Tablespaces
Thanks
NaveenUnless you are using an exceptionally old version of Oracle or are still using dictionary managed tablespaces or are using some interesting definitions of "fragmentation", fragmentation is practically impossible in Oracle.
Justin -
Guys,
Firstly let me say hello to the community. I am relatively new to OBIEE and can I apologise up front if some of my questions seem a little too straight forward.
I am trying to setup some aggregation on my tables. I have 4 tables: Actual Summary, Budget Summary, Forecast Summary and Actual Outlet (Outlet is a catalogue or a brochure). As you might have guessed I need to set an aggreation level for actual (We have a version dimension) so that any measure will get data from the summary table when outlet is not included in the report. That's easy enough, the complication is that we don't budget or forecast at outlet level and there will never be a budget outlet or forecast outlet table. Any idea how I would go about setting this up in the logical table fragmentation window?
Cheers,
Jim.answered by myself.
-
For reorganizing table what is the Probs/Cons & Mandatery checks.
Hi,
For reorganizing table on line what is the Probs/Cons & Mandatery checks.
I will reorganize FAGLFLEX Table ,Present table size 210GB.
My Questions are
1.What is the free space required in PSAPSR3 table space.
2. PSAPTEMP Tables pace required size.
3. PSAPUNDO Tables pace required size.
Pleas Help.
Edited by: Gabriel Samson on Nov 19, 2010 8:43 PMHi,
For reorganizing table on line what is the Probs/Cons
Refer Topic# 7 of [SAP Note 541538 - FAQ: Reorganization|https://service.sap.com/sap/support/notes/541538]. This Note address all the questions related to Reorganization.
First I would check how much wasted space is there for table FAGLFLEXA at database level.
Run the following SQL commnad to get such result. The result will include Top 40 Tables sorted by Wasted Space due to Table fragmentation.
The following SQL command is taken from [SAP Note 821687 - FAQ: Space utilization and fragmentation in Oracle|https://service.sap.com/sap/support/notes/821687]. Refer it to get more info.
First Update Database statistics before executing following query.
SELECT * FROM
(SELECT
SUBSTR(TABLE_NAME, 1, 21) TABLE_NAME,
NUM_ROWS,
AVG_ROW_LEN ROWLEN,
BLOCKS,
ROUND((AVG_ROW_LEN + 1) * NUM_ROWS / 1000000, 0) NET_MB,
ROUND(BLOCKS * (8000 - 23 * INI_TRANS) *
(1 - PCT_FREE / 100) / 1000000, 0) GROSS_MB,
ROUND((BLOCKS * (8000 - 23 * INI_TRANS) * (1 - PCT_FREE / 100) -
(AVG_ROW_LEN + 1) * NUM_ROWS) / 1000000) "WASTED_MB"
FROM DBA_TABLES
WHERE
NUM_ROWS IS NOT NULL AND
OWNER LIKE 'SAP%' AND
PARTITIONED = 'NO' AND
(IOT_TYPE != 'IOT' OR IOT_TYPE IS NULL)
ORDER BY 7 DESC)
WHERE ROWNUM <=40;
The result will tell you about how much space benefit you will get, if you reorganize such required tables.
What is the free space required in PSAPSR3 table space.
The required Space will be sum of Total Space of Table(s) and the sum of total space of their associated indexes. You can extend the default table space (of table owners) with that required size or You can create new Table space for such big tables and incorporate -n <new_table_sapce> option in Table Reorganization command so that the new table will be created in new table space after successful completion of table reorganization process.
2. PSAPTEMP Tables pace required size.
PSAPTEMP will be used during Index Creation activities. So It should be sufficient to handle such activity. Refer SAP Note 659946 to get more info.
3. PSAPUNDO Tables pace required size.
PSAPUNDO will be used to store "Before image of last consistent Data" of actual Table Data. In Table reorganization activity Materialized views will be created in default table space of table owner. Such Materialized vies will be used to record all changes of actual Table which happen while Table Reorganization activity.
Regards,
Bhavik G. Shroff -
Frequent truncation leads to fragmentation
Dear all,
We have a table with 4 million of rows which will truncated in a day and will be loaded with data(some 15 records).the retreival time for this 15 records is more than 45 minutes as the table is fragmented..so i use to do the following :
alter table tablename enable row movement;
alter table tablename shrink space;
alter table disable row movement;
This truncation and loading data is unavoidable and it is regular..what Can I do in this scenario ?
Please advise
KaiKaiS wrote:
To all Senior Peoples, in this Forum,
Please ignore any threads if you are not interested and if you find it silly .. Please understand that your PRECIOUS SENIOR time by doing this. So Please ignore the thread if you find it silly which doesn't comply with SENIORITY
Well that's a rude statement isn't it. You were told a simple thing which is trivial with the truncate statement. I am still waiting for the question's answers that I asked which I guess you just ignored. Let me ask again, how did you conclude that the table fragmentation is leading slow response time and the table is fragmentated after truncate? How did you conclude this? Answer this and we can proceed further.
There is no need to get upset. You have given a statement which doesn't comply with the basic concepts of Oracle and you are told the same thing. If you are going to delete and mention fragmentation, its genuine and understandable but with a whole table truncate, if you still say that the table is fragmentated than the whole difference of both the statements is nullified and that's what was told to you. Its not about being senior or junior, its about understanding the things correctly. I asked you the above mentioned question for which you didn't give any reply, may I ask why? Anyways, let's get back to the issue, do a trace of the query with 10046 trace before and after the truncate and post the results. Also , before and after the truncate the table , check the number of extents in the table in the dba_extents with the associated blocks too.
HTH
Aman...
Maybe you are looking for
-
How can i transfert song from my ipod to my itune list
i format my pc and all my song are store on my ipod , i reinstall itune but cant transfert song from my ipod into my library, it only give me choice to erase my toon on my ipod to replace it
-
HELP! - Mail 2.0.7 unexpectedly quits on attemt to configure priority field
PLEASE, ...if someone could point me to actions I haven't already tried, that would be MOST WELCOME. Here's what I already went through: - repaired permissions - maintainance, cron-scripts, cashes and all (Cocktail) - OS update to 10.6.4 (from 10.6.5
-
Why is my MacBook Pro slow?
My MacBook Pro became very slow. I tried to restart it but it wouldn't startup. I managed to start it in safe mode. Afther this it now starts up but is very slow. What can I do to make it fast again? Thanks
-
Good book on portal 10g v10.1.2 ??
Hi, I'm looking for a good book that covers all aspects of Portal 10g, including the installation of app server 10g v10.1.2, configuration of portal, and portal/portlet development. I have found books on app server 10g that have sections on portal, b
-
How do I sync my itunes to my iPhone 4S?
How do I sync my itunes to my iPhone 4S?