SlideShare a Scribd company logo
1 of 2
Download to read offline
Counting Extents                                                                Administration Tips




Counting Extents

When you want to determine the total number of extents a table has acquired, issue the
following command:

SELECT SEGMENT_NAME, COUNT(*) FROM DBA_EXTENTS
WHERE SEGMENT_NAME='NAME_OF_TABLE'
GROUP BY SEGMENT_NAME;


You'll get a report like this:

SEGMENT_NAME                              COUNT(*)
----------------------------------------- ----------
ALBUM                                         4

If you wish to see physical and size details for each extent, try this one:

SELECT SEGMENT_NAME, EXTENT_ID, FILE_ID, BLOCK_ID, BYTES, BLOCKS
FROM DBA_EXTENTS
WHERE SEGMENT_NAME='ALBUM';


SEGMENT_NAME EXTENT_ID   FILE_ID BLOCK_ID       BYTES BLOCKS
----------- ---------- ---------- ---------- ---------- --------
ALBUM                0        9        17     65536     16
ALBUM                1        9       321     65536     16
ALBUM                2        9       353     65536     16
ALBUM                3        9       369     65536     16

...and this starts to show important information -such as the fact that all the extents (in
this case) are of consistent size (good), and are all located on the one physical data file
(not so good, perhaps -all I/O will be hitting the one device).

The block_id column in this report shows you the first block of the relevant extent. From
the above report, it is apparent that these four extents are not lying contiguously next to
each other within the tablespace. The first extent starts at Block 17, and is 16 blocks long.
If the extents were contiguous, that would mean the next extent starting at Block 33 -
instead of which we see a dirty great 300ish-block gap before the next extent actually
starts at Block 321. In fact, the only contiguous extents are the last two: Block 353 plus 16
would mean the next extent should start at Block 369 -which it in fact then proceeds to do.

In this way, it's possible to convert a boring old set of raw numbers into a mind's-eye
picture of the extent layout of a segment. In our case, the picture (where 'X' marks data
and '-' marks something else -perhaps free space, perhaps another segment) would look
like this:

Copyright © Howard Rogers 2001             10/18/2001                                    Page 1 of 2
Counting Extents                                                               Administration Tips




|XXXXXXXXXXX|-----------------------------------------------|XXXXXXXX|--------|XXXXXX|XXXXXX|

(Incidentally, the fact that extents are not contiguous is not a performance problem at all,
and is not what is meant by 'fragmentation').

Knowing where your data is laid out within a tablespace is important when you check you
Alert Log and discover error messages along the lines of "Corrupt Block Detected, File 9,
Block 331" -since the first thing you'll want to know is "What segment was occupying Block
331 on File 9??!" From the above report, you can probably see that it would be part of the
second extent of the ALBUM table that was corrupted.

But what if the corruption had been reported for, say, File 9 block 342?

There's clearly a need to convert a file and block number into a corresponding segment
name, and the query to do that is this:

SELECT SEGMENT_NAME,SEGMENT_TYPE
FROM DBA_EXTENTS
WHERE FILE_ID=&FILE_ID
AND &BLOCK_ID BETWEEN BLOCK_ID AND (BLOCK_ID+BLOCKS-1);

When run, this will prompt you for the File Number and Block ID as reported in the Alert
Log, and it will then return the name of the affected segment. If it had been File 9, and
block 342, we'd get this sort of output:

ENTER    VALUE FOR FILE_ID: 9
OLD      3: WHERE FILE_ID=&FILE_ID
NEW      3: WHERE FILE_ID=9
ENTER    VALUE FOR BLOCK_ID: 342
OLD      4: AND &BLOCK_ID BETWEEN BLOCK_ID AND (BLOCK_ID+BLOCKS-1)
NEW      4: AND 342 BETWEEN BLOCK_ID AND (BLOCK_ID+BLOCKS-1)

SEGMENT_NAME               SEGMENT_TYPE
-------------------------- ------------------
SYS_IL0000032134C00002$$      LOBINDEX

… and now we know precisely the segment that’s in trouble!




Copyright © Howard Rogers 2001            10/18/2001                                    Page 2 of 2

More Related Content

Similar to Extentcount

How to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanHow to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanIvan Silva
 
Stack It And Unpack It
Stack It And Unpack ItStack It And Unpack It
Stack It And Unpack ItJeff Moss
 
PadsPlus User Guide
PadsPlus User GuidePadsPlus User Guide
PadsPlus User GuideYingda Qin
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on rAbhik Seal
 
Linux memorymanagement
Linux memorymanagementLinux memorymanagement
Linux memorymanagementpradeepelinux
 
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor boardLab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor boardKatrina Little
 
structenumtypedefunion.pptx
structenumtypedefunion.pptxstructenumtypedefunion.pptx
structenumtypedefunion.pptxKUPPALAPADMINI
 
Smashing the stack for fun and profit
Smashing the stack for fun and profitSmashing the stack for fun and profit
Smashing the stack for fun and profitAlexey Miasoedov
 
Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...
Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...
Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...Anne Nicolas
 
Memory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bitsMemory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bitsSomenath Mukhopadhyay
 
How to chtmultiregionfoam
How to chtmultiregionfoamHow to chtmultiregionfoam
How to chtmultiregionfoamEustache Gokpi
 

Similar to Extentcount (20)

How to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanHow to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by Ivan
 
Stack It And Unpack It
Stack It And Unpack ItStack It And Unpack It
Stack It And Unpack It
 
Capitulo 1 METRADO DE CARGAS
Capitulo 1 METRADO DE CARGASCapitulo 1 METRADO DE CARGAS
Capitulo 1 METRADO DE CARGAS
 
Linux.pdf
Linux.pdfLinux.pdf
Linux.pdf
 
NOTES ON "FOXPRO"
NOTES ON "FOXPRO" NOTES ON "FOXPRO"
NOTES ON "FOXPRO"
 
PadsPlus User Guide
PadsPlus User GuidePadsPlus User Guide
PadsPlus User Guide
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on r
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
 
Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
DSD
DSDDSD
DSD
 
Linux memorymanagement
Linux memorymanagementLinux memorymanagement
Linux memorymanagement
 
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor boardLab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
Lab 7 -RAM and ROM, Xilinx, Digelent BASYS experimentor board
 
structenumtypedefunion.pptx
structenumtypedefunion.pptxstructenumtypedefunion.pptx
structenumtypedefunion.pptx
 
SAS Commands
SAS CommandsSAS Commands
SAS Commands
 
Beginbackup
BeginbackupBeginbackup
Beginbackup
 
Smashing the stack for fun and profit
Smashing the stack for fun and profitSmashing the stack for fun and profit
Smashing the stack for fun and profit
 
AQA Computer science easter revision
AQA Computer science easter revisionAQA Computer science easter revision
AQA Computer science easter revision
 
Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...
Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...
Kernel Recipes 2014 - What I’m forgetting when designing a new userspace inte...
 
Memory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bitsMemory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bits
 
How to chtmultiregionfoam
How to chtmultiregionfoamHow to chtmultiregionfoam
How to chtmultiregionfoam
 

More from oracle documents (20)

Applyinga blockcentricapproachtotuning
Applyinga blockcentricapproachtotuningApplyinga blockcentricapproachtotuning
Applyinga blockcentricapproachtotuning
 
Windowsosauthent
WindowsosauthentWindowsosauthent
Windowsosauthent
 
Whatistnsnames
WhatistnsnamesWhatistnsnames
Whatistnsnames
 
Whatisadatabaselink
WhatisadatabaselinkWhatisadatabaselink
Whatisadatabaselink
 
Varraysandnestedtables
VarraysandnestedtablesVarraysandnestedtables
Varraysandnestedtables
 
Usertracing
UsertracingUsertracing
Usertracing
 
Userpasswrd
UserpasswrdUserpasswrd
Userpasswrd
 
Userlimit
UserlimitUserlimit
Userlimit
 
Undo internalspresentation
Undo internalspresentationUndo internalspresentation
Undo internalspresentation
 
Tablespacelmt
TablespacelmtTablespacelmt
Tablespacelmt
 
Tablerename
TablerenameTablerename
Tablerename
 
Sql scripting sorcerypresentation
Sql scripting sorcerypresentationSql scripting sorcerypresentation
Sql scripting sorcerypresentation
 
Sql scripting sorcerypaper
Sql scripting sorcerypaperSql scripting sorcerypaper
Sql scripting sorcerypaper
 
Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentation
 
Sequencereset
SequenceresetSequencereset
Sequencereset
 
Rollbacksizes
RollbacksizesRollbacksizes
Rollbacksizes
 
Rollbackshrinks
RollbackshrinksRollbackshrinks
Rollbackshrinks
 
Rollbacklmt
RollbacklmtRollbacklmt
Rollbacklmt
 
Rollbackblocking
RollbackblockingRollbackblocking
Rollbackblocking
 
Rollback1555s
Rollback1555sRollback1555s
Rollback1555s
 

Extentcount

  • 1. Counting Extents Administration Tips Counting Extents When you want to determine the total number of extents a table has acquired, issue the following command: SELECT SEGMENT_NAME, COUNT(*) FROM DBA_EXTENTS WHERE SEGMENT_NAME='NAME_OF_TABLE' GROUP BY SEGMENT_NAME; You'll get a report like this: SEGMENT_NAME COUNT(*) ----------------------------------------- ---------- ALBUM 4 If you wish to see physical and size details for each extent, try this one: SELECT SEGMENT_NAME, EXTENT_ID, FILE_ID, BLOCK_ID, BYTES, BLOCKS FROM DBA_EXTENTS WHERE SEGMENT_NAME='ALBUM'; SEGMENT_NAME EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS ----------- ---------- ---------- ---------- ---------- -------- ALBUM 0 9 17 65536 16 ALBUM 1 9 321 65536 16 ALBUM 2 9 353 65536 16 ALBUM 3 9 369 65536 16 ...and this starts to show important information -such as the fact that all the extents (in this case) are of consistent size (good), and are all located on the one physical data file (not so good, perhaps -all I/O will be hitting the one device). The block_id column in this report shows you the first block of the relevant extent. From the above report, it is apparent that these four extents are not lying contiguously next to each other within the tablespace. The first extent starts at Block 17, and is 16 blocks long. If the extents were contiguous, that would mean the next extent starting at Block 33 - instead of which we see a dirty great 300ish-block gap before the next extent actually starts at Block 321. In fact, the only contiguous extents are the last two: Block 353 plus 16 would mean the next extent should start at Block 369 -which it in fact then proceeds to do. In this way, it's possible to convert a boring old set of raw numbers into a mind's-eye picture of the extent layout of a segment. In our case, the picture (where 'X' marks data and '-' marks something else -perhaps free space, perhaps another segment) would look like this: Copyright © Howard Rogers 2001 10/18/2001 Page 1 of 2
  • 2. Counting Extents Administration Tips |XXXXXXXXXXX|-----------------------------------------------|XXXXXXXX|--------|XXXXXX|XXXXXX| (Incidentally, the fact that extents are not contiguous is not a performance problem at all, and is not what is meant by 'fragmentation'). Knowing where your data is laid out within a tablespace is important when you check you Alert Log and discover error messages along the lines of "Corrupt Block Detected, File 9, Block 331" -since the first thing you'll want to know is "What segment was occupying Block 331 on File 9??!" From the above report, you can probably see that it would be part of the second extent of the ALBUM table that was corrupted. But what if the corruption had been reported for, say, File 9 block 342? There's clearly a need to convert a file and block number into a corresponding segment name, and the query to do that is this: SELECT SEGMENT_NAME,SEGMENT_TYPE FROM DBA_EXTENTS WHERE FILE_ID=&FILE_ID AND &BLOCK_ID BETWEEN BLOCK_ID AND (BLOCK_ID+BLOCKS-1); When run, this will prompt you for the File Number and Block ID as reported in the Alert Log, and it will then return the name of the affected segment. If it had been File 9, and block 342, we'd get this sort of output: ENTER VALUE FOR FILE_ID: 9 OLD 3: WHERE FILE_ID=&FILE_ID NEW 3: WHERE FILE_ID=9 ENTER VALUE FOR BLOCK_ID: 342 OLD 4: AND &BLOCK_ID BETWEEN BLOCK_ID AND (BLOCK_ID+BLOCKS-1) NEW 4: AND 342 BETWEEN BLOCK_ID AND (BLOCK_ID+BLOCKS-1) SEGMENT_NAME SEGMENT_TYPE -------------------------- ------------------ SYS_IL0000032134C00002$$ LOBINDEX … and now we know precisely the segment that’s in trouble! Copyright © Howard Rogers 2001 10/18/2001 Page 2 of 2