disks and files part 2
play

Disks and Files (Part 2) Disk technology and how to make disk - PDF document

Outline Disks and Files (Part 2) Disk technology and how to make disk read/writes faster (last time) Buffer management Storing database files on disk (Chapter 9 of textbook)


  1. Outline Disks and Files (Part 2) � Disk technology and how to make disk read/writes faster (last time) � Buffer management � Storing “database files” on disk (Chapter 9 of textbook) �������������������������������������������� ������������������� �������������������������������������������� ������������������� Buffer Management in a DBMS When a Page is Requested ... #������$%�����"����&������'�(�)� �*++���#��' �����!��� "����"���� ����������� ��� ,���,���"�"�������,����� �� ��� ������������������ * ����������������������������������������������������� ������������������������ ������������������������ �������������������������������������������� ������������������� �������������������������������������������� �������������������

  2. More on Buffer Management In Class Exercise � Requestor of page must unpin it, and � What happens if the buffer is full and all indicate whether page has been modified frames have pin count > 0? � Page in pool may be requested many � What happens if multiple transactions times (users) want to access the same page? � CC & recovery may entail additional I/O when a frame is chosen for replacement. �������������������������������������������� ������������������� �������������������������������������������� ������������������� In Class Exercise Solution Buffer Replacement Policy � Frame is chosen for replacement by a replacement policy: � Least-recently-used (LRU) � Clock � Many others � First-in-first-out (FIFO), Most-recently-used (MRU), Random �������������������������������������������� ������������������� �������������������������������������������� �������������������

  3. Buffer Replacement Policy DBMS vs. OS File System (Contd.) OS does disk space & buffer mgmt: why not let � Policy can have big impact on # of I/O’s; OS manage these tasks? depends on the access pattern . � Ex: Sequential flooding �������������������������������������������� ������������������� �������������������������������������������� ������������������� Files of Records Outline � Page or block is OK when doing I/O, but � Disk technology and how to make disk higher levels of DBMS operate on records , read/writes faster (last time) and files of records . � Buffer management � FILE: A collection of pages, each � Storing “database files” on disk containing a collection of records. Must support: �������������������������������������������� ������������������� �������������������������������������������� �������������������

  4. Things to decide Record Formats: Fixed Length � Record format F1 F2 F3 F4 � Page format L1 L2 L3 L4 � File format �������������-�. ��������/��0'10'2 � Information about field types same for all records in a file; stored in system catalogs. � Finding i’th field requires scan of record. �������������������������������������������� ������������������� �������������������������������������������� ������������������� Record Formats: Variable Page Formats: Fixed Length Length Records � Two alternative formats (# fields is fixed): +1��������������������+2�������������������+6������������������� +3 �)���1 3 4 4 4 4 �)���2 +��� ����� +��)�����)�����������!�,��)������)� +��)� �!�,� 5�%�� �)���� +1�������������+2�������������+6�������������+3 � �%����� #�5 �� �"���,���� �������"�+��)���""���� �������������������������������������������� ������������������� �������������������������������������������� �������������������

  5. Page Formats: Fixed Length Page Formats: Variable Length Records Records ����/�-���. #����� ����/�-��2. �)���1 �)���2 ����/�-��1. +��� ����� �!�,� �)���� �)���� 27 19 23 � #������ 1 ����� 7 1 1 � �������� � �����������������2���������1 :��)��� �"�"��� ����������6��2��1 �%���� �!�,� *�#�5 ������8��# �"��)��� �'�8�����58��� * Can move records on page without changing rid; so, attractive for fixed-length records too . �������������������������������������������� ������������������� �������������������������������������������� ������������������� Unordered (Heap) Files Heap File Implemented as a List � Simplest file structure contains records in no particular order. ���� ���� ���� +%))�#���� #��� #��� #��� � As file grows and shrinks, disk pages are &����� allocated and de-allocated. #��� � To support record level operations, we must: ���� ���� ���� #�����;��� #��� #��� #��� � keep track of the pages in a file +�����!�,� � keep track of free space on pages � keep track of the records on a page � The header page id and Heap file name must � There are many alternatives for keeping track be stored someplace. of this. � Each page contains 2 `pointers’ plus data. �������������������������������������������� ������������������� �������������������������������������������� �������������������

Recommend


More recommend