DISK
7667 ワード
DISK-1
Disks and Files
DBMSリポジトリはハードディスクまたはフラッシュメモリSSDsを使用
CPU -> CPU Cache -> DRAM -> Disk
Capacity ($/GB) : Harddisk >> Flash SSD
Bandwidth(MB/秒):HDD
Disks
テープは以前は重要なストレージデバイスでした
ディスクは、リストア可能なため、ランダムアクセスの革新です.
隣接する場所にデータがある場合のみ、アクセス速度が遅くなります.
e.g. elevator disk scheduling algorithms
rpmが大きいほどアクセス速度が速くなります
Update-in-place, No atomic write, Fsync
Accessing a Disk Page
1)Seek time(headから所望の軌跡まで腕を動かす)
2)Rotational Delay(rpmに応じて必要なBlockに移動)
3)伝送時間(伝送速度)
Arranging Pages on Disk
「Next」block concept:同じトラック、柱面、または隣接する位置(順番)
Techniques to Hid IO Bottlenecks
1)プリフェッチ(プリフェッチ)
2) Caching
3) IO overlapping (CPU works while IO is performing)
-> Multiple threads
ディスクの機能強化
改善の容易さ:容量>帯域幅>遅延(改善が困難なため)
費用のため
メインメモリにすべて格納しないのはなぜですか?
コスト面、volatile(揮発性):データが更新されました
dram sizeとpowerの関係はexp形式である
RAID
SLED (Single Large Expensive Disk)
互いに独立した安価なディスクの組み合わせで、より高い価格の製品を創造することができますか?
目標:パフォーマンスと信頼性の向上
RAID 0 : nonredundant striping (IOPS, Bandwidth)
RAID 1:ミラーディスク(セキュリティ、以前は故障しやすい)
cf) Tesla Battery and Rocket Tech (engine)
DISK-2
FILE (per table)
Operations
1) Insert/delete/modify record
2) Fetch a particular record (specified using record id)
3) Scan all records (possibly wi
Unnordered(Heap)ファイル(一般)
To support record level operations
Heap File: Implemented as a List
Each page contains 2 ‘pointers’ plus data. (prev, next)
非効率
Heap File: Using a Page Directory
Oracle:
Tablespace, Segments, Extents, and Blocks
Table:論理DBMSのファイル
Segment:各テーブル、各インデックスにセグメント(物理概念)があります(ファイルポーリングテーブル)
Extent:セグメントを追加するときに物理的に割り当てられる単位(連続するディスクブロック)
Block(ページとも呼ばれる):サイズ設定可能
user_tables
COLUMN table_name FORMAT a10
COLUMN tablespace_name FORMAT a10
select table_name, tablespace_name, blocks, pct_free, avg_row_len, avg_space
from user_tables
where table_name = 'TEST'; /* TEST table in Ch9-Script.sql */
664*10+1410-8 KB(1ページサイズ)
conn scott/tiger as sysdba
COLUMN segment_name FORMAT a10
COLUMN segment_type FORMAT a10
SELECT segment_name, segment_type, header_file, header_block,
blocks,extents, max_extents
FROM dba_segments
WHERE segment_name = 'TEST';
COLUMN segment_name FORMAT a10
COLUMN tablespace_name FORMAT a10
SELECT segment_name, tablespace_name, extent_id, file_id, block_id, blocks
FROM dba_extents
WHERE segment_name = 'TEST';
8 KB*8=64 KBのextension
Page Formats: Fixed Length Records
record id =
文字タイプのサイズが異なる場合がありますので、変更する必要があります.
Page Formats: Variable Length Records
Tuple-Oriented, Slotted Page Structure
Block Dump in Oracle
conn scott/tiger as sysdba
select header_file, header_block, bytes, blocks
from dba_segments
where segment_name = ‘EMP';
alter system dump datafile 4 block min 27 block max 30;
--- Check the trace file in admin/udump/xxx.trc file.
ディスク・ページの「一般」データLayout:Row-store(行ごとに格納)
その他のLayouts:C-StoreとPax(カラム別)
Record Format:Fixed Length(初期アドレス+サイズx)/Variable Length(すべてアクセスする必要があります)
Row Layout in Oracle
オーバーフロー時に0 xFEを含む
Column Value in Oracle
=============== SQL DUMP function ===========
// dump() show s how a data value is stored in disk
select dump(a)
from test
where a = 1000;
DUMP(A)
-------------------------------
Typ=2 Len=2: 194,11 Integer value 1000: type 2: int, column lengh 2 byte
data value 1000 is represented as (194, 11)
System Catalogs(or Data Dictionary)
Full Table Scan: An Access Method
Oracle 9.2は、1000個ずつではなく、16個ずつ読み取ります.(でも実際は10.398)
Cost = 1000/10.4 + 1 = 98
OLAP vs. OLTP
On-Line { Analytical vs. Transactional} Processing
Point or Range Query
On-Line Transactional Processing
Index-based Table Access
ページにランダムにアクセスします.
DISK-3
Disk Space Management
allocate/de-allocate a page
read/write a page
Buffer Management in a DBMS
Buffer pool information table:
pin cnt:バッファが使用中であることを示す
Buffer Replacement Policy
Hit vs. miss
Hit ratio = # of hits/( # of page requests to buffer cache)
Problem: for the given (future) references, which victim should be chosen for highest hit ratio (i.e. least # of IOs)?
Frame is chosen for replacement by a replacement policy
Random, FIFO, LRU, MRU, LFU, Clock etc.
For a given workload, one replacement policy, A, achieves 90% hit ratio and the other, B, does 91%.
How much improvement? 1% or 10%?
Missでは10%/9%,10000回の追加IO,9000回であった.それなら10ドルと見なすことができます
Least Recently Used (LRU)
For each page in buffer pool, keep track of time last unpinned
Replace the frame that has the oldest (earliest) time
Problem of LRU - sequential flooding
MRU much better in this situation
“Clock” Algorithm
An approximation of LRU
do for each page in cycle {
if (pincount == 0 && ref bit is on)
turn off ref bit;
else if (pincount == 0 && ref bit is off)
choose this page for replacement;
} until a page is chosen
Belady’s MIN Algorithm
Theoretical optimal buffer replacement algorithm
最も遠い被害者に選ばれた
CPU-IO Overlapping
3 States: CPU Bound, IO Bound, Balanced
IOは毎秒どれだけ重要か.
サーバでHDDとSSDを混在させて容量/価格を管理
Five minute rule
アクセス頻度が5分を超える場合は、DRAMへの投資が必要となります
逆にDISKの方が優勢です
Reference
この問題について(DISK), 我々は、より多くの情報をここで見つけました https://velog.io/@icchris/DISK-1テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol