Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | InnoDB Spatial Index Jimmy Yang Copyright © 2014, Oracle and/or its affiliates.

Slides:



Advertisements
Similar presentations
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Advertisements

 Definition of B+ tree  How to create B+ tree  How to search for record  How to delete and insert a data.
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
Restart Trail for Stackless BVH Traversal Samuli Laine NVIDIA Research.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Chapter 4: Trees Part II - AVL Tree
Quick Review of Apr 10 material B+-Tree File Organization –similar to B+-tree index –leaf nodes store records, not pointers to records stored in an original.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
B+-trees. Model of Computation Data stored on disk(s) Minimum transfer unit: a page = b bytes or B records (or block) N records -> N/B = n pages I/O complexity:
Dr. Kalpakis CMSC 661, Principles of Database Systems Index Structures [13]
Chapter 15 B External Methods – B-Trees. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-2 B-Trees To organize the index file as an external search.
B+-tree and Hashing.
Data Structures Topic #9. Today’s Agenda Continue Discussing Trees Examine the algorithm to insert Examine the algorithm to remove Begin discussing efficiency.
Tree-Structured Indexes. Introduction v As for any index, 3 alternatives for data entries k* : À Data record with key value k Á Â v Choice is orthogonal.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
Spatial Information Systems (SIS) COMP Spatial access methods: Indexing.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part B Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
Spatio-Temporal Databases. Introduction Spatiotemporal Databases: manage spatial data whose geometry changes over time Geometry: position and/or extent.
1 Tree-Structured Indexes Chapter Introduction  As for any index, 3 alternatives for data entries k* :  Data record with key value k   Choice.
Chapter 4: Transaction Management
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
1 Indexing Structures for Files. 2 Basic Concepts  Indexing mechanisms used to speed up access to desired data without having to scan entire.
Homework #3 Due Thursday, April 17 Problems: –Chapter 11: 11.6, –Chapter 12: 12.1, 12.2, 12.3, 12.4, 12.5, 12.7.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
1 B+ Trees. 2 Tree-Structured Indices v Tree-structured indexing techniques support both range searches and equality searches. v ISAM : static structure;
CS4432: Database Systems II
B+ Review. B+ Tree: Most Widely Used Index Insert/delete at log F N cost; keep tree height- balanced. (F = fanout, N = # leaf pages) Minimum 50% occupancy.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 9.
Tree-Structured Indexes. Range Searches ``Find all students with gpa > 3.0’’ –If data is in sorted file, do binary search to find first such student,
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit The Newest JDE Module – Rental Management Joel Sandberg Sales Consultant.
Introduction to Database Systems1 B+-Trees Storage Technology: Topic 5.
Chapter 61 Chapter 6 Index Structures for Files. Chapter 62 Indexes Indexes are additional auxiliary access structures with typically provide either faster.
Indexing. Goals: Store large files Support multiple search keys Support efficient insert, delete, and range queries.
 B+ Tree Definition  B+ Tree Properties  B+ Tree Searching  B+ Tree Insertion  B+ Tree Deletion.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
B+ Trees COMP
Database Management 8. course. Query types Equality query – Each field has to be equal to a constant Range query – Not all the fields have to be equal.
Data Structures Balanced Trees 1CSCI Outline  Balanced Search Trees 2-3 Trees Trees Red-Black Trees 2CSCI 3110.
B + -Trees. Motivation An AVL tree with N nodes is an excellent data structure for searching, indexing, etc. The Big-Oh analysis shows that most operations.
CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Starting at Binary Trees
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes.
Index tuning-- B+tree. overview Overview of tree-structured index Indexed sequential access method (ISAM) B+tree.
R-Trees: A Dynamic Index Structure For Spatial Searching Antonin Guttman.
B+ Tree Index tuning--. overview B + -Tree Scalability Typical order: 100. Typical fill-factor: 67%. –average fanout = 133 Typical capacities (root at.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 B+-Tree Index Chapter 10 Modified by Donghui Zhang Nov 9, 2005.
Indexing Database Management Systems. Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files File Organization 2.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
CS4432: Database Systems II More on Index Structures 1.
1 Tree-Structured Indexes Chapter Introduction  As for any index, 3 alternatives for data entries k* :  Data record with key value k   Choice.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Content based on Chapter 10 Database Management Systems, (3 rd.
8/3/2007CMSC 341 BTrees1 CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Chapter 11 Indexing And Hashing (1) Yonsei University 1 st Semester, 2016 Sanghyun Park.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 10.
Database Applications (15-415) DBMS Internals- Part III Lecture 13, March 06, 2016 Mohammad Hammoud.
Mehdi Kargar Department of Computer Science and Engineering
COMP261 Lecture 23 B Trees.
Multiway Search Trees Data may not fit into main memory
Tree-Structured Indexes
B+ Trees What are B+ Trees used for What is a B Tree What is a B+ Tree
B+ Tree.
Binary Tree and General Tree
(edited by Nadia Al-Ghreimil)
Database Applications (15-415) DBMS Internals- Part III Lecture 15, March 11, 2018 Mohammad Hammoud.
B+-Trees and Static Hashing
Tree-Structured Indexes
B+Trees The slides for this text are organized into chapters. This lecture covers Chapter 9. Chapter 1: Introduction to Database Systems Chapter 2: The.
Tree-Structured Indexes
Presentation transcript:

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | InnoDB Spatial Index Jimmy Yang Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

SAFE HARBOR STATEMENT The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Overview InnoDB Spatial Index as R-tree Tree Search in InnoDB Spatial Index Predicate Lock Conclusion

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Overview InnoDB now supports Spatial Index in  The spatial index is implemented as an R-tree, which is a special tree structure for spatial access  Can be indexed on all geometric type supported by MySQL  Supports transactions and MVCC just like other indexes in InnoDB  Isolation levels are also observed, using predicate lock preventing phantom at serializable reads

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | InnoDB Spatial Index as R-tree R-Tree  A special data structure that used specifically for multi-dimension spatial data search.  Queries more like: find object “within”, “intersects”, “touches” another spatial object  In InnoDB, the tree is build on MySQL geometrics datatypes: POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRY

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | InnoDB Spatial Index as R-tree R-tree in InnoDB  For InnoDB spatial Index, the index itself does not contain the actual data. The data is stored in the Primary Index of Table  The InnoDB spatial index consists of MBR( Minimum Bounding Box) of the object and its Primary Key.  Once the search locates the correct MBR for the queries, the real data is then retrieved from the Primary index. And the operator could apply to the actual data again for results

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Search in InnoDB Spatial Index Unlike B-tree search, R- tree search needs to work on multiple subtrees Search is more like a recursive in-depth search

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Search in InnoDB Spatial Index Use a vector to cache all qualified entries in a non- leaf page Use a “shadow” buffer page to cache all qualified rows in a leaf page Once a page is exhausted, it returns to upper lever for more qualified leaf or non-leaf page

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Search in InnoDB Spatial Index Entries does not have sort order across pages Entries are sorted accord (minx, miny) in page Searches are done per page (all entries in a page are qualified once). Does not support position cursor in middle of page

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Insertion The insertion operation begins by traversing the tree along a single path from the root to a leaf  following branches with the lowest insert penalty MBR updates on parent - if the insertion of the new leaf entry will change the leaf’s MBR, the new MBR is propagated to the parent entries by moving up the tree, until an ancestor node is encountered whose BP does not need to expand;  we also “copy” search predicates from ancestor to child nodes, if the ancestors’ predicates are consistent with the child’s updated MBR; MBR Updates Insert

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Insertion Use SX lock on the tree for tree insert/split, so split can happen concurrently with search Predicate locking  Replace GAP lock for phantom prevention  Check the list of predicates attached to the leaf and block on the conflicting ones until their owner transactions commit When resuming the insertion, the leaf originally located might have been split. Recognized by comparing the memorized Split Sequence Number (SSN) with the leaf’s current SSN, followed by zero or more rightlink traversals.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Search/Insert synchronization with Split Sequence Number (SSN) SSN is per index, 8 bytes monotonically increase counter SSN is used to synchronize search with potential Insert Split SSN is on page header (overloads with field of FIL_PAGE_FILE_FLUSH_ LSN) Largest SSN used so far is ironed on the root page for crash recovery SSN to handle split

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Split Sequence Number (SSN) SSN is incremented for every split and put on the current page, the splitted right page inherits the SSN of current page Timestamp every page pointer stored on the stack with the value of the global counter as of the time the page pointer was read Page C NSN = 5 Page D NSN = 8 Page C NSN = 5 Page A NSN = 1 Page B NSN = 2 Page B NSN = 2

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Split Sequence Number (SSN) When search visit the node, it compares its recorded SSN with the node’s SSN. If the latter is higher, the node has been split, and then push the rightlink pointer of the node together with the originally recorded counter value on the stack. This guarantees that the right siblings split off the original node will also be examined later on Page C NSN = 5 Page D NSN = 8 Page C NSN = 5 Page A NSN = 1 Page B NSN = 2 Page B NSN = 2 Search NSN = 6

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Deletion Key deletion is similar to B- tree in following ways:  Marked an entry as deleted for delete operation  Purge delete when it is no longer needed  Direct delete happens only with rollback and purge Node shrink  We can't simply shrink out a node, it is possibly still in a search stack  avoid incorrect pointers altogether by delaying a node deletion until there can be no more active tree operations with pointers to it A CB D

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | DELETION The first alternative, recovery from incorrect pointers, is impossible – the right link!  If the node has been split before it is deleted, a tree operation visiting it after the deletion may still need to traverse its rightlink. If it is deleted, the rightlink page would be lost  Repositioning within the tree by revisiting the parent is also not possible, because the parent itself might have been split or simply changed. When that happens, it is impossible to determine which nodes have been split off the deleted one. D A CB

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Node Shrink - Solution A node cannot be deleted while active tree operations still hold direct or indirect pointers to it Use a page lock - place a S-lock on a node if it pushes a pointer to that node onto the stack.  insert and delete operations are not prevented from physically accessing and modifying that node  A node deletion checks for S-locks by trying to acquire an X-mode lock on the respective node.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Phantom Prevention and Predicate Lock No ordering for Geometry data GAP lock relies on ordering. So GAP lock does not work for R-tree Predicate Lock is used  Disadvantage on Generic Predicate lock “Generic” Predicate locks are less efficient to set and check. A search operation must set its predicate lock before the index is accessed and any data records are retrieved.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Predicate Lock A hybrid system  An efficient hybrid mechanism, which associates predicate lock with tree structure  data records that are scanned, inserted or deleted are still protected by the record locking protocol  Search operations set predicate locks to prevent phantom insertions  Only insert needs to check for predicate lock (the predicate lock is inhibitive)

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Predicate Lock Place a predicate lock by search  If a search operation’s predicate is consistent with a node’s BP, the predicate must be attached to the node. Test on predicate lock by insertion  An insert operation can therefore limit itself to checking only the predicates attached to its target leaf. The predicates and their node attachments are only removed when the owner transaction terminates.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Predicate Lock Dealing with Node Split  Predicate could be moved (if it fits for one node but not the other)  Predicate could be copied (if fits for both node MBR)  Predicate could be deleted (if it does not overlap with either MBR) Dealing with MBR expansion with insertion  Predicate need to be tested and copied from ancestor

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Predicate Lock Dealing with MBR expansion  Predicate need to be tested and copied from ancestor

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Predicate Lock-Implemenation Implementation  Different lock hash table as record hash table on lock_sys_t  Lock always on PAGE_HEAP_NO_INFIMUM (0) entry  Predicate is attached to the lock Right after lockstructure itself, after the lock entry bitmap

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Predicate Lock-Implemenation Implementation  Lock conflict checks both the LOCK_MODE and predicates attached  Similar to GAP lock, we have LOCK_S | LOCK_PREDICATES and LOCK_X | LOCK_PREDICATES  Locks are requalified and copied/deleted during an index split  Lock are requalified and copied to child during parent update

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Summary R-tree is traversed in a depth first approach with vector/stack to cached result Search and tree splits are synchronized using split sequence number (SSN) Page locks are used to prevent shrink out nodes that have active searching activity on it Predicate Locks are used to prevent phantom