Bài giảng Hệ quản trị cơ sở dữ liệu - Chương 10: Indexing
lượt xem 5
download
Index là phương tiện rất mạnh để tăng hiệu năng thực hiện của câu lệnh. Bài giảng chương 10 này sẽ cung cấp một số kiến thức liên quan đến Indexing để người học có thể nắm bắt được những tiện ích của công cụ index trong CSDL. Mời các bạn cùng tham khảo.
Bình luận(0) Đăng nhập để gửi bình luận!
Nội dung Text: Bài giảng Hệ quản trị cơ sở dữ liệu - Chương 10: Indexing
- Chương 10: Indexing 1
- 2 Why Concerning Storage and Indexing? • DB design using logical models (ER/Relational). – Appropriate level for designers to begin with – Provide independence from implementation details • Performance: another major factor in user satisfaction – Depends on • Efficient data structures for data representation • Efficiency of system operation on those structures – Disks contains data files and system files
- 3 Subjects to be Discussed • Disks: Can retrieve random page, but reading several consecutive pages is much cheaper than reading them in random order • Buffer manager: Stages pages from external storage to main memory buffer pool. File and index layers make calls to the buffer manager. • File organization: Method of arranging a file of records on external storage. – Record id (rid) is sufficient to physically locate record – Indexes are data structures that allow us to find the record ids of records with given values in index
- 4 Storage Hierarchy • DBMS stores information on some storage medium – Primary storage: can be operated directly by CPU. – Secondary storage: • larger capacity, lower cost, slower access • cannot be operated directly by CPU – must be copied to primary storage • Secondary storage has major implications for DBMS design – READ: transfer data to main memory – WRITE: transfer data from main memory. – Both transfers are high-cost operations, relative to
- 5 Why Not Store Everything in Main Memory? • Cost and size • Main memory is volatile: What’s the problem? • Typical storage hierarchy: – Factors: access speed, cost per unit, reliability – Cache and main memory (RAM) for currently used data: fast but costly – Flash memory: limited number of writes (and slow), non-volatile, disk-substitute in embedded systems – Disk for the main database (secondary storage). – Tapes for archiving older versions of the data (tertiary
- 6 Disks • Secondary storage device of choice. • Data is stored and retrieved in units called disk blocks or pages. • Unlike RAM, time to retrieve a disk page varies depending upon location on disk. – Therefore, relative placement of pages on disk has major impact on DBMS performance!
- 7 Components of a Disk • The platters spin • The arm assembly is moved in or out to position a head on a desired track. Tracks under heads make a cylinder (imaginary!). • Only one head reads/writes at any one time. • Block size is a multiple of sector size (which is fixed).
- 8 Accessing a Disk Page • Time to access (read/write) a disk block: – Seek time (moving arms to position disk head on track) – Rotational delay (waiting for block to rotate under head) – Transfer time (actually moving data to/from disk surface) • Seek time and rotational delay dominate. – Seek time varies from about 1 to 20msec – Rotational delay varies from 0 to 10msec
- 9 Arranging Pages on Disk • `Next’ block concept: – blocks on same track, followed by – blocks on same cylinder, followed by – blocks on adjacent cylinder • Blocks in a file should be arranged sequentially on disk (by `next’), to minimize seek and rotational delay. • For a sequential scan, pre-fetching several pages at a time is a big win!
- 10 Arranging Pages on Disk
- 11 RAID • Redundant Arrays of Independent Disks (RAID) • Disk Array: Arrangement of several disks that gives abstraction of a single, large disk. • Goals: Increase performance and reliability. • Two main techniques: parallelism and redundancy – Data striping: Data is partitioned; size of a
- 12 Disk Space Management • Lowest layer of DBMS software manages space on disk. • Higher levels call upon this layer to: – allocate/de-allocate a page – read/write a page • Highly desirable that a request for a sequence of pages to be satisfied by allocating the pages sequentially on disk.
- 13 Structure of a DBMS
- 14 Structure of a DBMS • A typical DBMS has a layered architecture. • The figure does not show the concurrency control and recovery components. • This is one of several possible architectures; each system has its own variations.
- 15 Buffer Management in a DBMS • Data must be in RAM for DBMS to operate on it. • Table of pairs is maintained.
- 16 When a Page is Requested ... • If requested page is not in pool: – Choose a frame for replacement – If frame is dirty, write it to disk – Read requested page into chosen frame • Pin the page and return its address. – If requests can be predicted (e.g., sequential scans) pages can be pre-fetched several pages at a time!
- 17 More on Buffer Management • Requestor of page must unpin it, and indicate whether page has been modified: – Dirty bit is used for this. • Page in pool may be requested many times, – A pin count is used. A page is a candidate for replacement iff pin count = 0. • CC & Recovery may require additional I/O when a frame is chosen for replacement.
- 18 Buffer Replacement Policy • Frame is chosen for replacement by a replacement policy: – Least-recently-used (LRU), Clock, MRU, etc. – Policy can have big impact on # of I/O’s; depends on the access pattern. • Sequential flooding: Nasty situation caused by LRU + repeated sequential scans. – # buffer frames < # pages in file means each
- 19 DBMS vs. OS File System • OS does disk space & buffer mgmt: why not let OS manage these tasks? – Differences in OS support: portability issues – Some limitations, e.g., files can’t span disks. – Buffer management in DBMS requires different abilities • Pin a page in buffer pool, force a page to disk (important for implementing CC & recovery), • Adjust replacement policy, and pre-fetch pages based on access patterns in typical DB operations.
- 20 File Organizations • Several alternatives exist, each ideal for some situations, and not so good in others: – Heap (random order) files: Suitable when typical access is a file scan retrieving all records. – Sorted files: Best if records must be retrieved in some order, or only a `range’ of records is needed. – Indexed files: For efficient searching
CÓ THỂ BẠN MUỐN DOWNLOAD
-
Bài giảng Hệ quản trị cơ sở dữ liệu Oracle: Chương 1 - Ngô Thùy Linh
31 p | 183 | 25
-
Bài giảng Hệ quản trị cơ sở dữ liệu Oracle: Chương 5 - Ngô Thùy Linh
34 p | 95 | 18
-
Bài giảng Hệ quản trị cơ sở dữ liệu Access - ĐH Phạm Văn Đồng
159 p | 112 | 17
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Tổng quan hệ quản trị CSDL SQL Server - TS. Lại Hiền Phương
50 p | 112 | 14
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 4 - ĐH Công nghiệp Thực phẩm
92 p | 148 | 11
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 1 - ĐH Công nghiệp Thực phẩm
31 p | 99 | 10
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Giới thiệu - Phạm Thọ Hoàn
14 p | 157 | 9
-
Bài giảng Hệ quản trị cơ sở dữ liệu Oracle - Trường ĐH Đồng Tháp
119 p | 35 | 8
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 1 - Nguyễn Thị Uyên Nhi
33 p | 84 | 6
-
Bài giảng Hệ quản trị cơ sở dữ liệu (Database Management Systems) - Bài 1.1: Tổng quan về Hệ quản trị cơ sở dữ liệu
5 p | 17 | 6
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 1 - Nguyễn Trường Sơn
29 p | 47 | 5
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 2 - Phạm Nguyên Thảo
39 p | 78 | 5
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 1 - Lê Thị Minh Nguyện
14 p | 72 | 4
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Các tác vụ quản trị hệ thống - TS. Lại Hiền Phương (Phần 3)
61 p | 53 | 4
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Các tác vụ quản trị hệ thống - TS. Lại Hiền Phương (Phần 1)
32 p | 52 | 4
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 6 - Nguyễn Thị Mỹ Dung
33 p | 58 | 4
-
Bài giảng Hệ quản trị cơ sở dữ liệu: Chương 6 - Phạm Nguyên Thảo
44 p | 51 | 3
-
Bài giảng Hệ quản trị cơ sở dữ liệu MSSQL 2005: Chương 7 - Hồ Thị Anh Đào
24 p | 63 | 2
Chịu trách nhiệm nội dung:
Nguyễn Công Hà - Giám đốc Công ty TNHH TÀI LIỆU TRỰC TUYẾN VI NA
LIÊN HỆ
Địa chỉ: P402, 54A Nơ Trang Long, Phường 14, Q.Bình Thạnh, TP.HCM
Hotline: 093 303 0098
Email: support@tailieu.vn