01 / 102CS 277: Database System Implementation Notes 4: Indexing
1 / 17
Télécharger la présentation
CS 277: Database System Implementation Notes 4: Indexing
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
Comment: {FILE,INDEX} may be contiguous or not (blocks chained) Notes 4
Question: • Can we build a dense, 2nd level index for a dense index? Notes 4
Notes on pointers: (1) Block pointer (sparse index) can be smaller than record pointer BP RP Notes 4
Notes on pointers: (2) If file is contiguous, then we can omit pointers (i.e., compute them) Notes 4
say: 1024 B per block R2 R1 R3 • if we want K3 block: • get it at offset • (3-1)1024 • = 2048 bytes R4 K1 K2 K3 K4 Notes 4
Sparse vs. Dense Tradeoff • Sparse: Less index space per record can keep more of index in memory • Dense: Can tell if any record exists without accessing file (Later: • sparse better for insertions • dense needed for secondary indexes) Notes 4
Terms • Index sequential file • Search key ( primary key) • Primary index (on Sequencing field) • Secondary index • Dense index (all Search Key values in) • Sparse index • Multi-level index Notes 4
Also: Pointers are record pointers (not block pointers; not computed) With secondary indexes: • Lowest level is dense • Other levels are sparse Notes 4
20 20 10 10 30 40 40 40 40 10 20 40 30 Duplicate values & secondary indexes another option... 10 Problem: variable size records in index! Notes 4
30 20 20 10 10 10 40 40 40 40 50 10 60 20 30 ... 40 Duplicate values & secondary indexes Another idea (suggested in class):Chain records with same key? • Problems: • Need to add fields to records • Need to follow chain to know records Notes 4
Why “bucket” idea is useful Indexes Records Name: primary EMP (name,dept,floor,...) Dept: secondary Floor: secondary Notes 4
Dept. index EMP Floor index Toy 2nd Query: Get employees in (Toy Dept) ^ (2nd floor) Intersect toy bucket and 2nd Floor bucket to get set of matching EMP’s Notes 4
cat dog Inverted lists This idea used in text information retrieval Documents ...the cat is fat ... ...was raining cats and dogs... ...Fido the dog ... Notes 4
IR QUERIES • Find articles with “cat” and “dog” • Find articles with “cat” or “dog” • Find articles with “cat” and not “dog” • Find articles with “cat” in title • Find articles with “cat” and “dog” within 5 words Notes 4