1
Storage and Indexing (continued)
CMPSCI 645 Mar 4, 2008
Slides Courtesy of R. Ramakrishnan and J. Gehrke
Storage and Indexing (continued) CMPSCI 645 Mar 4, 2008 Slides - - PowerPoint PPT Presentation
Storage and Indexing (continued) CMPSCI 645 Mar 4, 2008 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Today Index selection & performance tuning Storing data: disks and files 2 Cost of Operations Scan Equality Range
1
Slides Courtesy of R. Ramakrishnan and J. Gehrke
2
D(log2B + #matching pages)
D(logF1.5B + #matching pages)
.15B)
D(logF.15B + #matching recs)
4
5
6
7
Attributes in WHERE clause are candidates for index keys.
equality queries if there are many duplicates. Multi-attribute search keys should be considered when a
Choose indexes that benefit as many queries as possible.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
MAIN MEMORY DISK disk page free frame
BUFFER POOL
22
23
24
25
26
27
FILE: A collection of pages, each containing a
28
29
(heap file name, header page id) stored in a known place. Two doubly linked lists, for full pages & pages with space.
Upon insertion, scan the list of pages with space, or ask
Header Page Data Page Data Page Data Page Data Page Data Page Data Page Pages with Free Space Full Pages
30
Data Page 1 Data Page 2 Data Page N Header Page
DIRECTORY
31
32
Slot 1 Slot 2 Slot N PACKED N Free Space number
M 1 . . . M ... 3 2 1 UNPACKED, BITMAP Slot 1 Slot 2 Slot N Slot M 1 1 number
33
Can move records on page without changing rid; so, attractive
Page i Rid = (i,N) Rid = (i,2) Rid = (i,1) 20 16 24
Pointer to start
space
SLOT DIRECTORY N . . . 2 1
34
Information of a record type e.g., the number of fields
Fixed length record: (1) the number of fields is fixed,
Store fields consecutively in a record. Finding i’th field does not require scan of record. Base address (B)
Address = B+L1+L2
35
Variable length record: (1) number of fields is fixed, (2)
Two alternatives:
Scan
F1 F2 F3 F4 F1 F2 F3 F4 S1 S2 S3 S4 E4
36