Question – How can you have a single file in a single tablespace showing multiple free extents when there are no objects using any space in that file ? For example, from an 11.1.0.7 database:
SQL> select 2 * 3 from user_free_space 4 where 5 tablespace_name = 'TEST_8K' 6 order by 7 file_id, block_id 8 ; TABLESPACE_N FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO ------------ ---------- ---------- ---------- ---------- ------------ TEST_8K 3 128 1048576 128 3 TEST_8K 3 256 1048576 128 3 TEST_8K 3 384 1048576 128 3 TEST_8K 3 512 130023424 15872 3 4 rows selected.
The answer in this case is simple – here’s what I did just before running my query:
SQL> create table t1(n1 number); Table created. SQL> create table t2(n1 number); Table created. SQL> create table t3(n1 number); Table created. SQL> drop table t1; Table dropped. SQL> drop table t2; Table dropped. SQL> drop table t3; Table dropped. SQL>
This test is on 11.1.0.7; test_8k is my default tablespace, uses an 8KB block size (did you spot the clue) with 1MB uniform extents. The segments created immediately and I haven’t purged my recyclebin. Because I’ve dropped the tables Oracle includes their space in the “free space” views, but because I need to be able to flash them back into existence the segments can’t be coalesced into the adjacent free space.
Here’s a harder one – there are NO objects in this tablespace, and nothing hiding in the recyclebin:
SQL> select 2 * 3 from user_free_space 4 where 5 tablespace_name = 'TEST_2K' 6 order by 7 file_id, block_id 8 ; TABLESPACE_N FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO ------------ ---------- ---------- ---------- ---------- ------------ TEST_2K 7 512 58720256 28672 7 TEST_2K 7 29184 58720256 28672 7 TEST_2K 7 57856 58720256 28672 7 TEST_2K 7 86528 32505856 15872 7
And here’s the statement I executed (as SYS) just before I ran the query – so no chance that there’s anything hidden in the file:
create tablespace test_2k datafile 'C:\ORACLE\ORADATA\d11g\d11g\test_2k.dbf' SIZE 200M reuse blocksize 2k extent management local uniform size 4k segment space management manual ;
Update: 26th Feb
I’m sitting in Munich airport and boarding starts in 10 minutes, so just enough time to give an answer. I’ll start with a block dump of block 3 of the data file.Block dump from disk: buffer tsn: 22 rdba: 0x01c00003 (7/3) scn: 0x0b86.06d63ae4 seq: 0x01 flg: 0x04 tail: 0x3ae41e01 frmt: 0x02 chkval: 0x4e8a type: 0x1e=KTFB Bitmapped File Space Bitmap Hex dump of block: st=0, typ_found=1 Dump of memory from 0x0C112200 to 0x0C112A00 C112200 0000621E 01C00003 06D63AE4 04010B86 [.b.......:......] C112210 00004E8A 00000007 00000200 00000000 [.N..............] C112220 00000000 00003800 00000000 00000000 [.....8..........] C112230 00000000 00000000 00000000 00000000 [................] Repeat 123 times C1129F0 00000000 00000000 00000000 3AE41E01 [...............:] File Space Bitmap Block: BitMap Control: RelFno: 7, BeginBlock: 512, Flag: 0, First: 0, Free: 14336 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 ... 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000
This is a locally managed tablespace, so the third block of the file is the first bitmap space management block for the tablespace. The tablespace uses a 2KB block size (so the amount of space in the block for the bit map is slight under 2KB) and a 4KB uniform extent size (so each bit in the map represents 2 blocks/4KB in the tablespace).
As you can see from line 15, the first bit represents the extent starting at block 512, and there are 14,336 bits available (1,792 bytes), so the bitmap in the next block would start at block 512 + 2 * 14,336 = 512 * 28,672 = 29,184. This lines up exactly with the first chunk of free space reported in dba_free_space above.
As one of the comments indicated – the code that populates x$ktfbfe is probably called once for each bitmap space management block, and it doesn’t seem to bother trying to “coalesce” two free space fragments identified by adjacent bitmap blocks.
DIGITAL JUICE
No comments:
Post a Comment
Thank's!