1 / 31

CS511 Design of Database Management Systems

CS511 Design of Database Management Systems. Lecture 08: Generalized Search Trees Kevin C. Chang. Search Trees: Previous Approaches. Specialized search trees (yet another tree!): redundant code: most trees are very similar concurrency control, logging/recovery: tricky

Download Presentation

CS511 Design of Database Management Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS511Design of Database Management Systems Lecture 08: Generalized Search Trees Kevin C. Chang

  2. Search Trees: Previous Approaches • Specialized search trees (yet another tree!): • redundant code: most trees are very similar • concurrency control, logging/recovery: tricky • Trees for extensible data types: • B-tree for any data with linear ordering • e.g.: index titles (alph. ordering) with B-tree • problem: does not support natural queries • e.g.: WHERE book.title > “database”?

  3. GiST: Generalized Search Tree • General: cover B+-tree, R-tree, etc… • Extensible: • domain-specific data types & queries definable • Easy to extend: six “key methods” for a new tree • Efficient: match specialized trees • Reusable: concurrency, recovery for indexes

  4. Example: Indexing Book Titles • Titles for books: • T1 = “database optimization” • T2 = “web database” • T3 = “complexity of optimization algorithms” • T4 = “algorithms and complexity” • Indexable with (extensible) B+-tree? • linear ordering: T4, T3, T1, T2 • Note: Just an example for demonstrating GiST! • What we will do to index “titles” is not the best and typical way to index “textual data”! --- No notion of fuzzy “relevance”. • stay tuned for text and web search

  5. ?? Queries on Title? • Indexing is to help “query” processing • ?? What “predicates” to ask about titles?

  6. Queries on Title • Equality predicates: • WHERE book.title = “web databases” • Containment predicates: • WHERE book.title has “web” • Prefix predicates: • WHERE book.title start-with “web” • RegEx predicates: (generalize all the others) • WHERE book.title like “# web # database”

  7. Extensible B+-Tree for Titles • Observations: • indexed values have linear ordering: T4, T3, T1, T2 • keys simply designate separators: T4, c, T3, d, T1, w, T2 d c w T4: alg. … T3: complexity … T1: database … T2: web …

  8. ?? Using B+-Tree: What’s Wrong? • Range queries not sensible: title > “web”? • ?? What predicates can B+tree support: • ? equality, containing, prefix, regex? d c w T4: alg. … T3: complexity … T1: database … T2: web …

  9. GiST: Generalizing Balanced Search Trees • GiST is not universal (just reasonable generalization) • balanced tree of <key, ptr> pairs, keys can overlap • GRE test:R-Tree : B-Tree = ________ : R-Tree • ?? what is the key generalization? key1 key2 … … internal nodes (directory) leaf nodes (linked list)

  10. The Key Generalization: The Key • Key evolution: 1-D separator --> 2-D MBR --> predicates • R-Tree : B-Tree • generalizing key form 1-D line to 2-D area • bounding range to (minimal) bounding region • GiST : R-Tree • generalizing key from 2-D MBR to “predicates” • a predicate that all values v in subtree will satisfy • B-tree keys: • [k1:k2) --> contains([k1:k2), v) • R-tree keys: • (x1,y1,x2,y2) --> contains((x1,y1, x2,y2), v)

  11. ?? Gist for Title Indexing: Predicates Must first determine predicates: • What query predicates to support? • equality: equal(v, “web db”) • containing: has(v, “web”) • What key predicate to use? • ? any criteria for choosing key predicates? • ?? what do you suggest?

  12. GiST for Title Indexing: Predicates • Key predicates: Contains(S, v) SL SR {alg, comp, opt} {db, opt, web} SLL SLR SRL SRR {alg, comp} {comp, opt} {db, opt} {db, web} T4: alg. … T3: complexity … T1: database … T2: web …

  13. GiST: Built-in Tree Operations • Search(root R, predicate q) • Insert(root R, entry E, level l) • Delete(root R, entry E)

  14. GiST: Application-Specific Methods Search: • Consistent(E, q): search subtree E for predicate q? Labeling: • Union(E1, …, En): how to label the union of E1, …, En? Categorization: • Penalty(E1, E2): penalty for inserting E2 in subtree E1 • PickSplit(E1, …, En): how to split into two groups of entries Compression: (storage/time tradeoff) • Compress(E): E --> Ec • Decompress(Ec): --> E’ such that E.p implies E’.p

  15. Search Operation: Consistent Method • Search(root R, predicate q): • traverse subtrees where Consistent true • return leaf entries that are consistent

  16. Consistent Method # • Consistent(E, q): • can E.p and q both hold? • Title GiST: • key predicate: p = Contains(S, v) or simply S • e.g., SL = {alg, comp, opt} • e.g., SR = {db, opt, web} • Consistent(SL, has(v, “web”))? • ? how to implement? • Consistent(SR, equals(v, “web database”))? • ? how to implement?

  17. Insert Operation • Insert(root R, entry E, level l) • descend tree along least increase in Penalty • stop at level specified • if there is room at node, insert there • else split according to PickSplit • propagate changes using Union to adjust keys

  18. Title GiST: Insert • ?? Where to insert T5:“complexity of web algorithms” ? SL SR {alg, comp, opt} {db, opt, web} SLL SLR SRL SRR {alg, comp} {comp, opt} {db, opt} {db, web} T4: alg. … T3: complexity … T1: database … T2: web …

  19. Penalty Method • Penality(E1, E2): • penalty for inserting E2 in subtree E1 • Title GiST: • E2 with S ={comp,web, alg} • for T5:“complexity of web algorithms” • ? Where to insert? • root: SL = {alg, comp, opt} vs. SR = {db, opt, web}? • Penalty: • ? how to implement?

  20. PickSplit Method • PickSplit(E1, …, En): • how to split into two groups of entries • Title GiST: • suppose insert put the three in one node: • S1 = {alg, comp} • S2 = {comp, opt} • S3 = {comp, web, alg} (new) • ? how to split {S1, S2, S3} into two? • something similar to R-tree algorithm will do

  21. Union Method • Union(E1, …, En): • label of subtree with E1, …, En • Title GiST: • key predicate: p = Contains(S, v) or simply S • S1 = {alg, comp}, S2 = {comp, opt} • ? combined key = ? • Union(E1=(SL, ptr1), E2=(SR, ptr2)) = ? • ? how to implement?

  22. ?? Compress/Decompress Method? Key storage vs. search time tradeoff • Compress(E): E --> Ec • Decompress(Ec): --> E’.p can be broader than E.p • Lossy compression: may need more time for search • Title GiST: • ?? any suggestions?

  23. Title GiST: Compress/Decompress • Example 1: no compression • Compress(E) --> Ec = E • Decompress(Ec) --> E’ = Ec • Example 2: compress by taking word initials • Compress: {algorithm, complexity, optimization} --> {al, co, op} • Decompress: {al, co, op} --> {al*, co*, op*}

  24. GiST: No Magic • It promises (only) what its model is based on • It does not represent all possible index structure: • e.g.: duplicate objects by multiple inserts (R+-tree) • e.g.: support notion of distance and similarity • rather than Boolean based predicates • any more?

  25. Outlook: Indexability • Observation: • the simplest version of the Consistent method is a routine that always returns MAYBE-- which gives you a search tree of no efficiency • Big questions: • what is an index machinery? (analog: turing machine) • how do we characterize “workload”? (analog: languages) • can index always help in search? (analog: decidability, complexity) • what are the performance parameters? (analog: size of input) • what are the performance measure? (analog: time, space complexity) • Initial result: Hellerstein, Koutsoupias and Papadimitriou: On the Analysis of Indexing Schemes, PODS 97

  26. Quote: Research is Reasonable At first, I thought GiST is magic. I thought it would generalize and unify all possible search trees, and thus be the only thing you ever need for indexing. It turns out that there is no magic in GiST. It is simply a reasonable generalization of B/R-tree. There is perhaps no magic in any research. Each step of progress is reasonable-- which I think is a good news because it means reasonable efforts can lead us to substantial progress, just like what our predecessors have already achieved.

  27. What’s Next? • T3: The other silver bullet of relational Q. processing • access path selection: to enable query optimization

  28. End Of Talk

  29. How to Index Sets • S1 = {1, 2, 3, 5, 6, 9} • S2 = {1, 2, 5} • S3 = {0, 5, 6, 9} • S4 = {1, 4, 5, 8} • S5 = {0, 9} • S6 = {3, 5, 6, 7, 8} • S7 = {4, 7, 9}

  30. ?? Index Sets {0,1,2,3,5,6,9} {1,3,4,5,6,7,8,9} {0,5,6,9} {1,2,3,5,6,9} {1,3,4,5,6,7,8} {4,7,9} {0,9} {0,5,6,9} {1,2,3,5,6,9} {1,2,5} {1,4,5,8} {3,5,6,7,8} {4,7,9}

  31. ?? Index 1-D Vectors: How • data tuple = (starting point, 1-D vector) • ?? How to index? (0,2) (-2,-3) (3,3) (-1,-2) (0,-5)

More Related