Storage and File Structureالتخزين وبنية الملفات

الشريحة 1 من 20

مقدمة الفصل

ماذا ستتعلم في هذا الفصل

  1. Physical storage media, their classification and the storage hierarchy.
  2. Magnetic disks: structure, controller, subsystems, performance measures and block-access optimization.
  3. RAID: reliability via redundancy, performance via parallelism, RAID levels and choosing a level.
  4. File organization: fixed- and variable-length records, organization of records in files, the data dictionary.
  5. Storage access: blocks, the buffer manager and buffer-replacement policies.
تفاصيل المصدرالفصل 7 · الشريحة ⁦2⁩
المصدر
الفصل 7 · الشريحة ⁦2⁩

Classifying storage mediaتصنيف الوسائط

Classification of physical storage media

Classified by (slide 3)

  • speed of access
  • cost per unit of data
  • reliability
  • Reliability covers data loss on power failure or system crash and physical failure of the storage device (slide 3).
  • Main memory: fast access; capacities of up to a few gigabytes widely used currently; capacities have gone up and per-byte costs have decreased steadily and rapidly; volatile — contents are usually lost if a power failure or system crash occurs (slide 4).
  • Flash memory: increasingly used as a replacement for magnetic disks for storing moderate amounts of data; writes are slow (few microseconds); widely used in embedded devices such as digital cameras, phones and USB keys (slide 5).

Volatileمتطاير

  • Loses contents when power is switched off.
  • Cache — fastest and most costly; managed by hardware.
  • Main memory — fast, generally too small or too expensive for the whole database.

Non-volatileغير متطاير

  • Contents persist when power is switched off.
  • Secondary and tertiary storage, and battery-backed-up main memory.
  • Flash memory — survives power failure; reads roughly as fast as main memory, writes slow, erase slower.

Which storage loses its contents when the power is switched off?

تفاصيل المصدرالفصل 7 · الشرائح ⁦3–5⁩
المصدر
الفصل 7 · الشرائح ⁦3–5⁩

Disk, optical and tape storageالقرص والضوئي والشريط

Classification of physical storage media

Physical storage media (slides 6–8)
MediumالوسيطKey factsأهم الحقائق
Magnetic disk
  • Data stored on a spinning disk, read/written magnetically
  • primary medium for long-term storage (typically the entire database)
  • data must be moved to main memory for access and written back for storage — much slower access than main memory
  • direct-access (read in any order, unlike magnetic tape)
  • capacities up to roughly 1.5 TB as of 2009 — much larger capacity and cost/byte than main memory/flash, growing constantly and rapidly
  • survives power failures and system crashes (disk failure can destroy data, but is rare)
Optical storage
  • Non-volatile, data read optically from a spinning disk using a laser
  • CD-ROM (640 MB) and DVD (4.7 to 17 GB) most popular
  • Blu-ray 27 GB to 54 GB
  • write-once, read-many (WORM) disks for archival storage (CD-R, DVD-R, DVD+R)
  • multiple-write versions (CD-RW, DVD-RW, DVD+RW, DVD-RAM)
  • reads and writes slower than magnetic disk
  • juke-box systems with many removable disks, a few drives and automatic loading/unloading
Tape storage
  • Non-volatile
  • used primarily for backup (to recover from disk failure) and archival data
  • sequential-access — much slower than disk
  • very high capacity (40 to 300 GB tapes)
  • tape can be removed from the drive ⇒ storage much cheaper than disk, but drives are expensive
  • tape jukeboxes store massive amounts of data — hundreds of terabytes (1 terabyte = 10⁹ bytes, as printed) to multiple petabytes (1 petabyte = 10¹² bytes, as printed)

Tape storage is used primarily for:

تفاصيل المصدرالفصل 7 · الشرائح ⁦6–8⁩
المصدر
الفصل 7 · الشرائح ⁦6–8⁩
ملاحظات حول المصدر (1)
  • الشريحة 8 تكتب أن التيرابايت = 10⁹ بايت والبيتابايت = 10¹² بايت، كما نُقل هنا.

The storage hierarchyهرم التخزين

From fastest to slowest (slide 9)

  1. 1

    Cache

  2. 2

    Main memory

  3. 3

    Flash memory

  4. 4

    Magnetic disk

  5. 5

    Optical disk

  6. 6

    Magnetic tapes

Levels of the hierarchy (slide 10)
LevelالمستوىPropertiesالخصائصExamplesأمثلة
Primary storageFastest, volatileCache, main memory
Secondary (on-line) storageNon-volatile, moderately fastFlash memory, magnetic disks
Tertiary (off-line) storageNon-volatile, slowMagnetic tape, optical storage

Magnetic tape and optical storage belong to which level of the storage hierarchy?

تفاصيل المصدرالفصل 7 · الشرائح ⁦9–10⁩
المصدر
الفصل 7 · الشرائح ⁦9–10⁩

Magnetic disk structureبنية القرص

Magnetic disks and disk subsystems

Slides 11–12

  • Slide 11 labels the parts of the disk mechanism: spindle, track t, sector s, cylinder c, platter, read–write head, arm, arm assembly, rotation (the diagram is schematic and simplifies actual disk drives).
  • Read-write head: positioned very close to the platter surface (almost touching it); reads or writes magnetically encoded information.
  • Typical sectors per track: 500 to 1000 (inner tracks) to 1000 to 2000 (outer tracks).
  • To read/write a sector: the disk arm swings to position the head on the right track; the platter spins continually and data is read/written as the sector passes under the head.
  • Head-disk assemblies: multiple platters on a single spindle (1 to 5 usually), one head per platter, mounted on a common arm.
Trackمسار
A circular division of the platter surface (over 50K–100K per platter).
Sectorقطاع
A division of a track — the smallest unit of data that can be read or written (typically 512 bytes).
Cylinder iأسطوانة
The ith track of all the platters.

The disk controller (slide 13)

  • Accepts high-level commands to read or write a sector, and moves the arm.
  • Computes and attaches checksums to each sector to verify data is read back correctly.
  • Ensures successful writing by reading back the sector after writing it.
  • Performs remapping of bad sectors.

Slide 13

  • Earlier generation disks were susceptible to head-crashes: metal-oxide coatings could disintegrate and damage all data on the disk; current disks are less susceptible, although individual sectors may get corrupted.
  • If data is corrupted, with very high probability the stored checksum won't match the recomputed checksum.

What is the smallest unit of data that can be read or written on a magnetic disk?

تفاصيل المصدرالفصل 7 · الشرائح ⁦11–13⁩
المصدر
الفصل 7 · الشرائح ⁦11–13⁩

Disk subsystems: SAN and NASSAN وNAS

Magnetic disks and disk subsystems

  • Slide 14 draws a disk controller on the system bus with four disks attached: multiple disks connected to a computer system through a controller.
  • Controller functionality (checksum, bad sector remapping) is often carried out by individual disks, reducing load on the controller.
  • Interface families: ATA (AT adaptor), SATA (Serial ATA), SCSI (Small Computer System Interconnect), SAS (Serial Attached SCSI); several variants of each (different speeds and capabilities).
  • Disks are usually connected directly to the computer system (slide 15).

Disk interface standards (slide 14)

  • ATA
  • SATA
  • SCSI
  • SAS

Storage Area Network (SAN)SAN

  • A large number of disks connected by a high-speed network to a number of servers.

Network Attached Storage (NAS)NAS

  • Networked storage that provides a file system interface using a networked file system protocol, instead of a disk system interface.

Which storage provides a file system interface over a networked file system protocol, instead of a disk system interface?

تفاصيل المصدرالفصل 7 · الشرائح ⁦14–15⁩
المصدر
الفصل 7 · الشرائح ⁦14–15⁩

Disk performance measuresأداء القرص

Performance measures of disks

Access time
From when a read or write request is issued to when data transfer begins: seek time + rotational latency.
Seek timeزمن البحث
Time to reposition the arm over the correct track; average = 1/2 the worst case; 4 to 10 ms.
Rotational latencyالتأخر الدوراني
Time for the sector to appear under the head; average = 1/2 the worst case; 4 to 11 ms.
Data-transfer rateمعدل النقل
Rate at which data is retrieved from or stored to the disk; 25 to 100 MB/s max, lower for inner tracks.
MTTFمتوسط الزمن حتى العطل
Average time the disk runs continuously without failure; typically 3 to 5 years; decreases as the disk ages.

Slides 16–17

  • Average seek time would be 1/3 of the worst case if all tracks had the same number of sectors, ignoring the time to start and stop arm movement.
  • Rotational latency 4 to 11 ms on typical disks (5400 to 15000 r.p.m.).
  • Multiple disks may share a controller, so the rate the controller can handle is also important: SATA 150 MB/sec, SATA-II 3Gb (300 MB/sec); Ultra 320 SCSI 320 MB/s, SAS 3 to 6 Gb/sec; Fiber Channel (FC2Gb or 4Gb) 256 to 512 MB/s.
  • Probability of failure of new disks is quite low, corresponding to a "theoretical MTTF" of 500,000 to 1,200,000 hours for a new disk (slide 17).

المسألة

A new disk has an MTTF of 1,200,000 hours. What does this mean for 1000 relatively new disks? (slide 17)

المعطيات

MTTF
1,200,000 hours
Disks
1000

Disk access time is made up of:

تفاصيل المصدرالفصل 7 · الشرائح ⁦16–17⁩
المصدر
الفصل 7 · الشرائح ⁦16–17⁩

Blocks and access optimizationتحسين الوصول

Optimizing disk-block access

Block
A logical unit of a fixed number of contiguous sectors from a single track; data is transferred between disk and main memory in blocks (typically 4 to 16 KB).

Smaller blocksكتل أصغر

  • More transfers from disk.

Larger blocksكتل أكبر

  • More space wasted due to partially filled blocks.
  • Block sizes range from 512 bytes to several kilobytes (slide 18).
  • Elevator algorithm figure (slide 18): requests R6, R3, R1, R5, R2, R4 lie from the inner track to the outer track; the arm serves them sweeping toward the outer track, then back toward the inner track.
  • Fragmentation: data inserted to/deleted from the file, or free blocks scattered so a new file has its blocks scattered — sequential access then means increased arm movement (slide 19).
  • Non-volatile RAM: even if power fails, the data is safe and will be written to disk when power returns; the controller writes to disk when there are no other requests or a request has been pending for some time; database operations needing safe storage can continue without waiting (slide 20).
  • A log disk is used exactly like nonvolatile RAM, with no need for special hardware (NV-RAM) (slide 20).
  • Disk-arm scheduling (e.g., the elevator algorithm) orders pending accesses to minimize arm movement.
  • Store related information on the same or nearby cylinders; fragmented files increase arm movement — defragment utilities help.
  • Nonvolatile write buffers (battery-backed RAM or flash) make writes safe and fast; writes can be reordered.
  • A log disk writes a sequential log of block updates — very fast since no seeks are required.
  • Journaling file systems write in safe order; reordering without journaling risks corruption.

Why is writing to a log disk very fast?

تفاصيل المصدرالفصل 7 · الشرائح ⁦18–20⁩
المصدر
الفصل 7 · الشرائح ⁦18–20⁩

RAID: why and howRAID

RAID: redundancy and parallelism

RAID — Redundant Arrays of Independent Disks
Manage many disks as one disk of high capacity and high speed (disks in parallel) and high reliability (data stored redundantly). "I" originally meant inexpensive; today it is independent.

المسألة

100 disks, each with MTTF 100,000 hours (≈ 11 years). What is the MTTF of the whole system? (slide 21)

المعطيات

Disks
100
MTTF each
100,000 hours
  • Mirroring (shadowing): duplicate every disk; writes go to both, reads to either; data is lost only if a disk and its mirror both fail before repair — e.g., mean time to data loss of 500 × 10⁶ hours (57,000 years).
  • Parallelism goals: load-balance small accesses (throughput) and parallelize large accesses (response time).
  • Block-level striping: with n disks, block i goes to disk (i mod n) + 1. Bit-level striping (bit i of each byte to disk i) is not used much any more.
  • Redundancy: store extra information that is not needed normally, but can be used in the event of failure of a disk to rebuild the lost information (slide 22).
  • Mirroring: a logical disk consists of two physical disks; the combined-failure probability is very small except for dependent failure modes such as fire, building collapse or electrical power surges.
  • Mean time to data loss depends on mean time to failure and mean time to repair: MTTF of 100,000 hours and mean time to repair of 10 hours give 500 × 10⁶ hours (57,000 years) for a mirrored pair (ignoring dependent failure modes).
  • Bit-level striping: in an array of eight disks, each access can read data at eight times the rate of a single disk, but seek/access time is worse than for a single disk (slide 23).
  • Block-level striping: requests for different blocks can run in parallel; a long sequence of blocks can use all disks in parallel (slide 23).
  • RAID was originally a cost-effective alternative to large, expensive disks; today RAIDs are used for their higher reliability and bandwidth (slide 21).

With block-level striping over n disks, where does block i of a file go?

تفاصيل المصدرالفصل 7 · الشرائح ⁦21–23⁩
المصدر
الفصل 7 · الشرائح ⁦21–23⁩

RAID levelsمستويات RAID

RAID levels (slides 24–29)
LevelالمستوىSchemeالطريقةNotesملاحظات
0
  • Block striping
  • non-redundant
High-performance applications where data loss is not critical
1Mirrored disks with block striping
  • Best write performance
  • popular for log files
2Memory-style ECC with bit stripingSubsumed by level 3
3Bit-interleaved parity
  • One parity bit corrects (the failed disk is known)
  • not used anymore
4Block-interleaved parity on a separate diskParity disk is a bottleneck for independent block writes
5Block-interleaved distributed parity (all N + 1 disks)Subsumes level 4 without the parity-disk bottleneck
6P+Q redundancy
  • Guards against multiple disk failures
  • higher cost
  • not used as widely
  • RAID levels: schemes to provide redundancy at lower cost by using disk striping combined with parity bits; different levels have differing cost, performance and reliability (slide 24).
  • Slides 24–29 draw each level: (a) RAID 0 four disks; (b) RAID 1 four disks and four copies (C); (c) RAID 2 four disks and three parity disks (P); (d) RAID 3 four disks and one parity disk; (e) RAID 4 four disks and one parity disk; (f) RAID 5 five disks, each holding parity; (g) RAID 6 six disks with P and Q.
  • RAID 3: faster data transfer than a single disk, but fewer I/Os per second since every disk participates in every I/O; subsumes level 2 (slide 26).
  • RAID 4: higher I/O rates for independent block reads than level 3; high transfer rates for reads of multiple blocks; before writing a block, parity must be computed — from the old parity block, old and new value of the block (2 block reads + 2 block writes), or by recomputing from the new values of the blocks (more efficient for large sequential writes) (slide 27).
  • RAID 5: higher I/O rates than level 4 — block writes occur in parallel if the blocks and their parity blocks are on different disks (slide 29).
  • To recover a damaged disk/block in levels 3–5: compute the XOR of the corresponding bits/blocks of the other disks (including parity).
  • Level 5 with 5 disks: the parity block of the nth set of blocks is on disk (n mod 5) + 1.
RAID 5 with 5 disks (slide 28): P0–P4 are the parity blocks, the numbers are data blocks
Disk 1Disk 2Disk 3Disk 4Disk 5
P00123
4P1567
89P21011
121314P315
16171819P4

How does RAID 5 improve on RAID 4?

تفاصيل المصدرالفصل 7 · الشرائح ⁦24–29⁩
المصدر
الفصل 7 · الشرائح ⁦24–29⁩

Choosing a RAID levelاختيار المستوى

Factors in choosing a RAID level (slide 30)

  • monetary cost
  • performance (I/O operations per second, bandwidth)
  • performance during failure
  • performance during rebuild of failed disk

Rules (slides 30–31)

  • RAID 0 only when data safety is not important.
  • Levels 2 and 4 are never used — subsumed by 3 and 5. Level 3 is not used anymore. Level 6 is rarely used.
  • Level 1: much better write performance than level 5 — level 5 needs at least 2 block reads + 2 block writes per block write; level 1 only 2 block writes. Preferred for high-update environments such as log disks.
  • Level 5: preferred for applications with low update rate and large amounts of data; level 1 for all other applications.
  • RAID 0 e.g. when data can be recovered quickly from other sources; level 3 is not used since bit-striping forces single block reads to access all disks; level 6 is rarely used since levels 1 and 5 offer adequate safety for most applications (slide 30).
  • Level 1 had higher storage cost than level 5, but disk capacities grow rapidly (50%/year) while access times decreased much less (×3 in 10 years); I/O requirements have increased greatly (e.g. Web servers); when enough disks are bought for the I/O rate they often have spare capacity — so there is often no extra monetary cost for Level 1 (slide 31).
Hot swappingالتبديل الساخن
Replacement of a disk while the system is running, without power down.
Data scrubbingتنظيف البيانات
Continually scan for latent failures (data written earlier that gets damaged) and recover from copy/parity.

Hardware issues (slides 32–33)

  • Software RAID: implemented entirely in software, with no special hardware support. Hardware RAID: special hardware; uses non-volatile RAM to record writes being executed (slide 32).
  • Beware: power failure during write can result in a corrupted disk (e.g. after writing one block but before the second in a mirrored system); corrupted data must be detected when power is restored — recovery is like recovery from a failed disk; NV-RAM helps detect potentially corrupted blocks efficiently, otherwise all blocks must be read and compared with mirror/parity (slide 32).
  • Latent failures can result in data loss even if only one disk fails; hot swapping is supported by some hardware RAID systems and reduces time to recovery; many systems keep spare disks online to replace failed disks immediately; redundant power supplies with battery backup and multiple controllers and interconnections guard against single points of failure (slide 33).

A database stores its log files, which are updated constantly. Which RAID level is preferred?

تفاصيل المصدرالفصل 7 · الشرائح ⁦30–33⁩
المصدر
الفصل 7 · الشرائح ⁦30–33⁩

Fixed-length records and free listsالسجلات الثابتة

File organization and records

  • A database is a collection of files; a file is a sequence of records; a record is a sequence of fields.
  • Record i starts at byte n × (i − 1) (n = record size); records may cross blocks — so do not allow records to cross block boundaries.
Fileملف
A collection of data stored in one unit, identified by a filename (slide 35).
Recordسجل
A collection of related fields.
Fieldحقل
The basic unit of the data, which contains a single data value.
  1. 1CompactالضغطMove records i + 1, …, n to i, …, n − 1.
  2. 2Move the last recordنقل الأخيرMove record n to i.
  3. 3Free listالقائمة الحرةDo not move records; **link all free records on a free list**.
Free list
The file header stores the address of the first deleted record; that record stores the address of the second, and so on — the addresses act as pointers. More space efficient: reuse the free records' attribute space for the pointers.

In a file of fixed-length records using a free list, where is the address of the first deleted record kept?

تفاصيل المصدرالفصل 7 · الشرائح ⁦35, 36, 39⁩
المصدر
الفصل 7 · الشرائح ⁦35, 36, 39⁩

Deleting a fixed-length record: the three alternativesحذف سجل

File organization and records

The file of fixed-length instructor records (slide 36)
RecordIDnamedept_namesalary
record 010101SrinivasanComp. Sci.65000
record 112121WuFinance90000
record 215151MozartMusic40000
record 322222EinsteinPhysics95000
record 432343El SaidHistory60000
record 533456GoldPhysics87000
record 645565KatzComp. Sci.75000
record 758583CalifieriHistory62000
record 876543SinghFinance80000
record 976766CrickBiology72000
record 1083821BrandtComp. Sci.92000
record 1198345KimElec. Eng.80000
Deleting record 3 and compacting (slide 37): records 4–11 move up
RecordIDnamedept_namesalary
record 010101SrinivasanComp. Sci.65000
record 112121WuFinance90000
record 215151MozartMusic40000
record 432343El SaidHistory60000
record 533456GoldPhysics87000
record 645565KatzComp. Sci.75000
record 758583CalifieriHistory62000
record 876543SinghFinance80000
record 976766CrickBiology72000
record 1083821BrandtComp. Sci.92000
record 1198345KimElec. Eng.80000
Deleting record 3 and moving the last record (slide 38): record 11 takes its place
RecordIDnamedept_namesalary
record 010101SrinivasanComp. Sci.65000
record 112121WuFinance90000
record 215151MozartMusic40000
record 1198345KimElec. Eng.80000
record 432343El SaidHistory60000
record 533456GoldPhysics87000
record 645565KatzComp. Sci.75000
record 758583CalifieriHistory62000
record 876543SinghFinance80000
record 976766CrickBiology72000
record 1083821BrandtComp. Sci.92000
Free list (slide 39): records 1, 4 and 6 are deleted; the header points to record 1, record 1 to record 4, record 4 to record 6, and record 6 ends the list
RecordIDnamedept_namesalary
headerلا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.→ record 1
record 010101SrinivasanComp. Sci.65000
record 1لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.→ record 4
record 215151MozartMusic40000
record 322222EinsteinPhysics95000
record 4لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.→ record 6
record 533456GoldPhysics87000
record 6لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.لا تذكر الشرائح شيئًا هنا.(end of list)
record 758583CalifieriHistory62000
record 876543SinghFinance80000
record 976766CrickBiology72000
record 1083821BrandtComp. Sci.92000
record 1198345KimElec. Eng.80000
  • No pointers are stored in in-use records (slide 39).
تفاصيل المصدرالفصل 7 · الشرائح ⁦36–39⁩
المصدر
الفصل 7 · الشرائح ⁦36–39⁩

Variable-length records and slotted pagesالسجلات المتغيرة

File organization and records

Variable-length records (slide 40)

  • Arise from multiple record types in a file, variable-length fields (varchar), and repeating fields.
  • Variable-length attributes are stored as a fixed-size (offset, length), with the actual data after all fixed-length attributes.
  • Null values are represented by a null-value bitmap.
A variable-length record (slide 40), byte by byte; the null bitmap is stored in 1 byte
BytesContents
0–3(21, 5) — offset and length of the first variable-length attribute
4–7(26, 10)
8–11(36, 10)
12–1965000
20null bitmap 0000
21–2510101
26–35Srinivasan
36–45Comp. Sci.

Slotted page structure (slide 41)

  • The header holds the number of record entries, the end of free space in the block, and the location and size of each record.
  • Records can be moved within the page to stay contiguous; the header entry is updated.
  • Pointers point to the record's entry in the header, not directly to the record — this indirection lets records move without breaking pointers.
  • Slide 41 figure: a block header with # Entries, End of Free Space and a (size, location) entry per record; free space in the middle; records at the end of the block, each header entry pointing to its record.
  • Attributes are stored in order; variable-length records arise from repeating fields used in some older data models (slide 40).
  • This level of indirection allows records to be moved to prevent fragmentation of space inside a block, while supporting indirect pointers to the record (slide 41).

In the slotted page structure, why do pointers point to the record's header entry rather than directly to the record?

تفاصيل المصدرالفصل 7 · الشرائح ⁦40–41⁩
المصدر
الفصل 7 · الشرائح ⁦40–41⁩

Organizing records in filesتنظيم السجلات

Organization of records in files

Heapكومة
A record can be placed anywhere in the file where there is space; no ordering.
Sequentialتتابعي
Records stored in sequential order based on the value of the search key.
Hashingتجزئة
A hash function on some attribute specifies the block in which the record is placed.
Multitable clusteringتجميع متعدد الجداول
Records of several different relations in the same file — related records on the same block to minimize I/O.
  • Heap: typically there is a single file for each relation (slide 42).
  • Sequential: suitable for applications that require sequential processing of the entire file; the records are ordered by a search-key (slide 43).
  • Slide 43 draws the 12 instructor records in ID order, each pointing to the next; slide 44 inserts 32222 Verdi Music 48000 into an overflow block at the end and links it into the pointer chain.

Sequential file maintenance (slide 44)

  • Deletion: use pointer chains.
  • Insertion: insert at the right position if there is free space; otherwise in an overflow block; update the pointer chain.
  • Reorganize the file from time to time to restore sequential order.

In which file organization can a record be placed anywhere in the file where there is space, with no ordering?

تفاصيل المصدرالفصل 7 · الشرائح ⁦42–44⁩
المصدر
الفصل 7 · الشرائح ⁦42–44⁩

Multitable clustering: the exampleمثال التجميع

Organization of records in files

department (slide 45)
dept_namebuildingbudget
Comp. Sci.Taylor100000
PhysicsWatson70000
instructor (slide 45)
IDnamedept_namesalary
10101SrinivasanComp. Sci.65000
33456GoldPhysics87000
45565KatzComp. Sci.75000
83821BrandtComp. Sci.92000
Multitable clustering of department and instructor (slides 45–46): each department record is followed by its instructors; slide 46 adds a pointer from the Comp. Sci. record to the Physics record
dept_name / IDbuilding / namebudget / salary
Comp. Sci.Taylor100000
45564Katz75000
10101Srinivasan65000
83821Brandt92000
PhysicsWatson70000
33456Gold87000
تفاصيل المصدرالفصل 7 · الشرائح ⁦45–46⁩
المصدر
الفصل 7 · الشرائح ⁦45–46⁩
ملاحظات حول المصدر (1)
  • الشريحتان 45 و46 تكتبان رقم Katz في الملف المجمّع 45564، بينما جدول instructor في الشريحة نفسها يكتبه 45565. نُقل كما طُبع.

Multitable clustering and the data dictionaryالتجميع والقاموس

Organization of records in files

Multitable clustering of department and instructor (slide 46)

Good forجيد لـ

  • Queries involving department ⋈ instructor.
  • Queries involving one single department and its instructors.

Bad forسيئ لـ

  • Queries involving only department.
  • Results in variable size records (pointer chains can link records of one relation).
Data dictionary (system catalog)
Stores metadata — data about data: names of relations and their attributes (names, types, lengths); views; integrity constraints; user and accounting information, including passwords; statistics (number of tuples in each relation); how and where each relation is stored; information about indices.
Relational representation of system metadata (slide 48): relational representation on disk; specialized data structures designed for efficient access, in memory. **Bold** = underlined.
RelationAttributes
Relation_metadatarelation_name, number_of_attributes, storage_organization, location
Attribute_metadatarelation_name, attribute_name, domain_type, position, length — relation_name points to Relation_metadata
User_metadatauser_name, encrypted_password, group
Index_metadataindex_name, relation_name, index_type, index_attributes — relation_name points to Relation_metadata
View_metadataview_name, definition

Which item is stored in the data dictionary (system catalog)?

تفاصيل المصدرالفصل 7 · الشرائح ⁦46–48⁩
المصدر
الفصل 7 · الشرائح ⁦46–48⁩

Blocks, buffers and the buffer managerمدير المخزن المؤقت

Storage access and the buffer manager

  • A database file is partitioned into fixed-length blocks — units of both storage allocation and data transfer.
  • The goal: minimize the number of block transfers by keeping as many blocks as possible in main memory.
  • Buffer: the portion of main memory storing copies of disk blocks. Buffer manager: the subsystem that allocates buffer space.

When a program requests a block (slide 50)

  1. 1

    If the block is already in the buffer, return its address in main memory.

  2. 2

    Otherwise allocate space, replacing another block if required; the replaced block is written back to disk only if it was modified.

  3. 3

    Read the block from disk into the buffer and return its address.

  • Programs call on the buffer manager when they need a block from disk (slide 50).
  • The replaced block is written back to disk only if it was modified since the most recent time that it was written to/fetched from the disk (slide 50).

The buffer manager must replace a block to make space. When is the replaced block written back to disk?

تفاصيل المصدرالفصل 7 · الشرائح ⁦49–50⁩
المصدر
الفصل 7 · الشرائح ⁦49–50⁩

Buffer-replacement policiesسياسات الاستبدال

Storage access and the buffer manager

  • Most operating systems replace the least recently used block (LRU) — the past pattern of references predicts future references.
  • LRU can be a bad strategy for repeated scans of data, e.g., a nested-loops join (for each tuple of r, for each tuple of s …).
  • A mixed strategy with hints from the query optimizer is preferable.
  • Queries have well-defined access patterns (such as sequential scans), and a database system can use the information in a user's query to predict future references (slide 51).
  • The nested loop of slide 51: for each tuple tr of r do / for each tuple ts of s do / if the tuples tr and ts match …
  • The buffer manager can use statistical information regarding the probability that a request will reference a particular relation (slide 52).
Pinned blockكتلة مثبتة
A memory block that is not allowed to be written back to disk.
Toss-immediateالتحرير الفوري
Frees the space of a block as soon as the final tuple of that block has been processed.
Most recently used (MRU)الأحدث استخدامًا
Pin the block being processed; after its final tuple it is unpinned and becomes the most recently used block (replaced first).
  • Keep data-dictionary blocks in the buffer (they are frequently accessed).
  • Buffer managers support forced output of blocks for recovery.

Why can LRU be a bad buffer-replacement strategy for a nested-loops join of r and s?

تفاصيل المصدرالفصل 7 · الشرائح ⁦51–52⁩
المصدر
الفصل 7 · الشرائح ⁦51–52⁩

الخلاصة

تفاصيل المصدر
المصدر
الفصل 7

خريطة الفصل

    1. 1مقدمة الفصل
  1. Classification of physical storage mediaتصنيف وسائط التخزين المادية

    1. 2Classifying storage mediaتصنيف الوسائط
    2. 3Disk, optical and tape storageالقرص والضوئي والشريط
    1. 4The storage hierarchyهرم التخزين
  2. Magnetic disks and disk subsystemsالأقراص المغناطيسية وأنظمتها

    1. 5Magnetic disk structureبنية القرص
    2. 6Disk subsystems: SAN and NASSAN وNAS
  3. Performance measures of disksمقاييس أداء الأقراص

    1. 7Disk performance measuresأداء القرص
  4. Optimizing disk-block accessتحسين الوصول إلى الكتل

    1. 8Blocks and access optimizationتحسين الوصول
  5. RAID: redundancy and parallelismRAID: التكرار والتوازي

    1. 9RAID: why and howRAID
    1. 10RAID levelsمستويات RAID
  6. Choosing a RAID level; hardware issuesاختيار مستوى RAID ومسائل العتاد

    1. 11Choosing a RAID levelاختيار المستوى
  7. File organization and recordsتنظيم الملفات والسجلات

    1. 12Fixed-length records and free listsالسجلات الثابتة
    2. 13Deleting a fixed-length record: the three alternativesحذف سجل
    3. 14Variable-length records and slotted pagesالسجلات المتغيرة
  8. Organization of records in filesتنظيم السجلات في الملفات

    1. 15Organizing records in filesتنظيم السجلات
    2. 16Multitable clustering: the exampleمثال التجميع
    3. 17Multitable clustering and the data dictionaryالتجميع والقاموس
  9. Storage access and the buffer managerالوصول إلى التخزين ومدير المخزن المؤقت

    1. 18Blocks, buffers and the buffer managerمدير المخزن المؤقت
    2. 19Buffer-replacement policiesسياسات الاستبدال
    1. 20الخلاصة