データが存在するデータファイルの確認


(8.0.26)
http://k-1-ne-jp.blogspot.com/2013/08/ibd.html

基本的にテーブルはインデックスも含めてテーブルごとにibdファイルに格納
特にサイズ上限はない模様

 


(19c)

サイズ固定で8M,16M,24Mのファイルを有する表領域を作成
この表領域を使用するテーブルを作成し、データを投入
各ファイルに存在するデータ件数を確認

 

drop tablespace tbs1 including contents and datafiles;

create tablespace tbs1 datafile '/u01/app/oracle/oradata/ORCL/pdb1/tbs1_01.dbf' size 8M autoextend off;

alter tablespace tbs1 add datafile '/u01/app/oracle/oradata/ORCL/pdb1/tbs1_02.dbf' size 16M autoextend off;
alter tablespace tbs1 add datafile '/u01/app/oracle/oradata/ORCL/pdb1/tbs1_03.dbf' size 24M autoextend off;

 

select * from dba_data_files order by file_id;
select * from dba_tablespaces;

 

drop table tab1 purge;
create table tab1(col1 int, col2 nchar(1000)) tablespace tbs1;

insert into tab1 select row_number() over(order by owner),'dummy' from dba_tab_columns fetch first 1000 rows only;
commit;


select rowid,col1,col2 from tab1 fetch first 100 rows only;


select col1,rowid, dbms_rowid.rowid_object(rowid) from tab1 fetch first 3 rows only;
select col1,rowid, dbms_rowid.rowid_relative_fno(rowid) from tab1 fetch first 3 rows only;
select col1,rowid, dbms_rowid.rowid_block_number(rowid) from tab1 fetch first 3 rows only;
select col1,rowid, dbms_rowid.rowid_row_number (rowid) from tab1 fetch first 3 rows only;


select dbms_rowid.rowid_relative_fno(rowid),count(*)
from tab1
group by dbms_rowid.rowid_relative_fno(rowid)
order by dbms_rowid.rowid_relative_fno(rowid)
;


DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)   COUNT(*)
------------------------------------ ----------
                                  44        354
                                  45        268
                                  46        378

データファイルはファイルサイズに関係なくおよそ均等に使用される


(14)

/usr/pgsql-14/bin/oid2name
/usr/pgsql-14/bin/oid2name -d test
/usr/pgsql-14/bin/oid2name -d test -i


基本的にテーブルやインデックスはそれぞれ1ファイルに格納

最大サイズは1Gで、それを超えると
41375.1
41375.2
のような名前で新ファイルが追加作成される

 


(2022)

サイズ固定で8M,16M,24Mのファイルを有するファイルグループを作成
このファイルグループを使用するテーブルを作成し、データを投入
各ファイルに存在するデータ件数を確認


use master
go

alter database test remove file f11;
alter database test remove file f12;
alter database test remove file f13;
alter database test remove filegroup fg1;

alter database test add filegroup fg1;

alter database test add file
(name = N'f11',
 filename = N'c:\data\f11.ndf',
 size = 8mb,
 filegrowth = 0
) to filegroup fg1
;

alter database test add file
(name = N'f12',
 filename = N'c:\data\f12.ndf',
 size = 16mb,
 filegrowth = 0
) to filegroup fg1
;

alter database test add file
(name = N'f13',
 filename = N'c:\data\f13.ndf',
 size = 24mb,
 filegrowth = 0
) to filegroup fg1
;

 

use test
go
select * from sys.filegroups;
select * from sys.database_files;

drop table tab1;
create table tab1(col1 int, col2 nchar(1000)) on fg1;

insert into tab1 select top 1000 row_number() over(order by object_id),'dummy' from sys.columns;


select top 100 t1.col1,t1.col2,t2.file_id,t2.page_id,t2.slot_id
from tab1 t1
cross apply sys.fn_PhysLocCracker(%%physloc%%) as t2
order by t2.file_id, t2.page_id, t2.slot_id
;


select t.file_id,count(*)
from 
(
select t1.col1,t1.col2,t2.file_id,t2.page_id,t2.slot_id
from tab1 t1
cross apply sys.fn_PhysLocCracker(%%physloc%%) as t2
) t
group by t.file_id
order by t.file_id
;

3    128
4    416
5    456