DOC PREVIEW
Berkeley COMPSCI 186 - File Organizations and Indexing

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

File Organizations and IndexingContextAlternative File OrganizationsCost Model for AnalysisSome Assumptions in the AnalysisCost of OperationsSlide 7Slide 8Slide 9Slide 10Slide 11IndexesFirst Question to Ask About IndexesIndex BreakdownAlternatives for Data Entry k* in IndexAlternatives for Data Entries (Contd.)Slide 17Index ClassificationClustered vs. Unclustered IndexUnclustered vs. Clustered IndexesSlide 21Composite Search KeysSummarySummary (Contd.)File Organizations and IndexingLecture 4R&G Chapter 8"If you don't find it in the index, look very carefully through the entire catalogue." -- Sears, Roebuck, and Co., Consumer's Guide, 1897ContextQuery Optimizationand ExecutionRelational OperatorsFiles and Access MethodsBuffer ManagementDisk Space ManagementDBAlternative File OrganizationsMany alternatives exist, each good for some situations, and not so good in others:–Heap files: Suitable when typical access is a file scan retrieving all records.–Sorted Files: Best for retrieval in search key order, or only a `range’ of records is needed.–Clustered Files (with Indexes): Coming soon…Cost Model for AnalysisWe ignore CPU costs, for simplicity:–B: The number of data blocks–R: Number of records per block–D: (Average) time to read or write disk block–Measuring number of block I/O’s ignores gains of pre-fetching and sequential access; thus, even I/O cost is only loosely approximated. –Average-case analysis; based on several simplistic assumptions. Good enough to show the overall trends!Some Assumptions in the Analysis•Single record insert and delete.•Equality selection - exactly one match (what if more or less???).•Heap Files:–Insert always appends to end of file.•Sorted Files:–Files compacted after deletions.–Selections on search key.Cost of Operations B: The number of data pagesR: Number of records per pageD: (Average) time to read or write disk pageHeap File Sorted File Clustered FileScan all recordsEquality SearchRange SearchInsertDeleteCost of Operations B: The number of data pagesR: Number of records per pageD: (Average) time to read or write disk pageHeap File Sorted File Clustered FileScan all recordsBD BDEquality SearchRange SearchInsertDeleteCost of Operations B: The number of data pagesR: Number of records per pageD: (Average) time to read or write disk pageHeap File Sorted File Clustered FileScan all recordsBD BDEquality Search0.5 BD (log2 B) * DRange SearchInsertDeleteCost of Operations B: The number of data pagesR: Number of records per pageD: (Average) time to read or write disk pageHeap File Sorted File Clustered FileScan all recordsBD BDEquality Search0.5 BD (log2 B) * DRange SearchBD [(log2 B) + #match pg]*DInsertDeleteCost of Operations B: The number of data pagesR: Number of records per pageD: (Average) time to read or write disk pageHeap File Sorted File Clustered FileScan all recordsBD BDEquality Search0.5 BD (log2 B) * DRange SearchBD [(log2 B) + #match pg]*DInsert2D ((log2B)+B)D (because R,W 0.5)DeleteCost of Operations B: The number of data pagesR: Number of records per pageD: (Average) time to read or write disk pageHeap File Sorted File Clustered FileScan all recordsBD BDEquality Search0.5 BD (log2 B) * DRange SearchBD [(log2 B) + #match pg]*DInsert2D ((log2B)+B)DDelete0.5BD + D ((log2B)+B)D (because R,W 0.5)Indexes•Sometimes, we want to retrieve records by specifying the values in one or more fields, e.g.,–Find all students in the “CS” department–Find all students with a gpa > 3•An index on a file is a disk-based data structure that speeds up selections on the search key fields for the index.–Any subset of the fields of a relation can be the search key for an index on the relation.–Search key is not the same as key (e.g. doesn’t have to be unique ID).•An index contains a collection of data entries, and supports efficient retrieval of all records with a given search key value k.First Question to Ask About Indexes•What kinds of selections do they support?–Selections of form field <op> constant–Equality selections (op is =)–Range selections (op is one of <, >, <=, >=, BETWEEN)–More exotic selections:•2-dimensional ranges (“east of Berkeley and west of Truckee and North of Fresno and South of Eureka”)–Or n-dimensional•2-dimensional distances (“within 2 miles of Soda Hall”)–Or n-dimensional•Ranking queries (“10 restaurants closest to Berkeley”)•Regular expression matches, genome string matches, etc.•One common n-dimensional index: R-tree–Supported in Oracle and Informix–See http://gist.cs.berkeley.edu for research on this topicIndex Breakdown•What selections does the index support•Representation of data entries in index–i.e., what kind of info is the index actually storing?–3 alternatives here•Clustered vs. Unclustered Indexes•Single Key vs. Composite Indexes•Tree-based, hash-based, otherAlternatives for Data Entry k* in Index•Three alternatives:- Actual data record (with key value k)- <k, rid of matching data record>- <k, list of rids of matching data records>•Choice is orthogonal to the indexing technique.–Examples of indexing techniques: B+ trees, hash-based structures, R trees, …–Typically, index contains auxiliary information that directs searches to the desired data entries•Can have multiple (different) indexes per file.–E.g. file sorted by age, with a hash index on salary and a B+tree index on name.Alternatives for Data Entries (Contd.)•Alternative 1: Actual data record (with key value k)–If this is used, index structure is a file organization for data records (like Heap files or sorted files).–At most one index on a given collection of data records can use Alternative 1. –This alternative saves pointer lookups but can be expensive to maintain with insertions and deletions.Alternatives for Data Entries (Contd.)Alternative 2 <k, rid of matching data record> and Alternative 3 <k, list of rids of matching data records>–Easier to maintain than Alt 1. –If more than one index is required on a given file, at most one index can use Alternative 1; rest must use Alternatives 2 or 3.–Alternative 3 more compact than Alternative 2, but leads to variable sized data entries even if search keys are of fixed length.–Even worse, for large rid lists the data entry would have to span multiple blocks!Index Classification•Clustered vs. unclustered: If order of data records is the same as, or `close to’,


View Full Document

Berkeley COMPSCI 186 - File Organizations and Indexing

Documents in this Course
Load more
Download File Organizations and Indexing
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view File Organizations and Indexing and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view File Organizations and Indexing 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?