Overview of Storage and IndexingWhy Concerning Storage and Indexing?Subjects to be DiscussedStorage HierarchyWhy Not Store Everything in Main Memory?DisksComponents of a DiskAccessing a Disk PageArranging Pages on DiskSlide 10RAIDDisk Space ManagementStructure of a DBMSBuffer Management in a DBMSWhen a Page is Requested ...More on Buffer ManagementBuffer Replacement PolicyDBMS vs. OS File SystemFile OrganizationsEfficient SearchingCost Model for Our AnalysisAssumptions used for AnalysisCost of OperationsIndexIndex file and Data FileB+ Tree IndexesExample B+ TreeHash-Based IndexesStatic HashingDynamic HashingExampleInsert h(r)=20 (Causes Doubling) --- How to determine keys in A and A2?Data Entry k* in IndexAlternatives for Data Entry k* in IndexAlternatives for Data Entries (Contd.)Slide 36Index ClassificationDense vs Sparse IndexClustered IndexClustered vs. Unclustered IndexUnderstanding the WorkloadChoice of IndexesChoice of Indexes (Contd.)Index Selection GuidelinesExamples of Clustered IndexesSlide 46Slide 47Indexes with Composite Search KeysComposite Search KeysSummarySummary (Contd.)Slide 52Exercise1Overview of Storage and IndexingChapter 8“How index-learning turns no student paleYet holds the eel of science by the tail.”-- Alexander Pope (1688-1744)2Why Concerning Storage and Indexing? DB design using logical models (ER/Relational).Appropriate level for designers to begin withProvide independence from implementation detailsPerformance: another major factor in user satisfactionDepends on•Efficient data structures for data representation•Efficiency of system operation on those structuresDisks contains data files and system files including dictionary and index filesDisk access: one of the most critical factor in performance.3Subjects to be DiscussedDisks: Can retrieve random page, but reading several consecutive pages is much cheaper than reading them in random orderBuffer 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 recordIndexes are data structures that allow us to find the record ids of records with given values in index search key fields4Storage Hierarchy DBMS stores information on some storage mediumPrimary 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 storageSecondary storage has major implications for DBMS designREAD: transfer data to main memoryWRITE: transfer data from main memory.Both transfers are high-cost operations, relative to in-memory operations, so must be planned carefully5Why Not Store Everything in Main Memory?Cost and sizeMain memory is volatile: What’s the problem?Typical storage hierarchy:Factors: access speed, cost per unit, reliabilityCache and main memory (RAM) for currently used data: fast but costlyFlash memory: limited number of writes (and slow), non-volatile, disk-substitute in embedded systemsDisk for the main database (secondary storage).Tapes for archiving older versions of the data (tertiary storage).6DisksSecondary 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!7Components of a Disk Platters The platters spinSpindle The arm assembly is moved in or out to position a head on a desired track. Tracks under heads make a cylinder (imaginary!).Disk headArm movementArm assembly Only one head reads/writes at any one time.TracksSector Block size is a multiple of sector size (which is fixed).8Accessing a Disk PageTime 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 20msecRotational delay varies from 0 to 10msecTransfer rate is less than 1msec per 4KB pageKey to lower I/O cost: reduce seek/rotation delays9Arranging Pages on Disk`Next’ block concept: blocks on same track, followed byblocks on same cylinder, followed byblocks on adjacent cylinderBlocks 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!10PlattersSpindleDisk headArm movementArm assemblyTracksSector11RAIDRedundant Arrays of Independent DisksDisk Array: Arrangement of several disks that gives abstraction of a single, large disk.Goals: Increase performance and reliability. Two main techniques: parallelism and redundancyData striping: Data is partitioned; size of a partition is called the striping unit. Partitions are distributed over multiple disks.Redundancy: More disks -> more failures. Redundant information allows reconstruction of data if a disk fails.RAID levels: level 0 – level 612Disk Space ManagementLowest layer of DBMS software manages space on disk.Higher levels call upon this layer to:allocate/de-allocate a pageread/write a pageHighly desirable that a request for a sequence of pages to be satisfied by allocating the pages sequentially on disk.13Structure of a DBMSA 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.Query Optimizationand ExecutionRelational OperatorsFiles and Access MethodsBuffer ManagementDisk Space ManagementDBThese layers must consider concurrencycontrol and recovery14Buffer Management in a DBMSData must be in RAM for DBMS to operate on it.Table of <frame#, pageid> pairs is maintained.DBMAIN MEMORYDISKdisk pagefree framePage Requests from Higher LevelsBUFFER POOLchoice of frame dictatedby replacement policy15When a Page is Requested ...If requested page is not in pool:Choose a frame for replacementIf frame is dirty, write it to diskRead requested page into chosen framePin the page and return its
View Full Document