indexing
play

Indexing December 12, 2008 Indexing Introduction New tuple is - PowerPoint PPT Presentation

Indexing December 12, 2008 Indexing Introduction New tuple is stored without any order next available space Indexing Introduction New tuple is stored without any order next available space Access will require inspection of every tuple


  1. Indexing December 12, 2008 Indexing

  2. Introduction New tuple is stored without any order next available space Indexing

  3. Introduction New tuple is stored without any order next available space Access will require inspection of every tuple SELECT name, salary FROM department WHERE name LIKE ’A%’; requires visiting each row for comparison since no alphabetical storage Indexing

  4. Introduction Indexing: speeds up access to desired data e.g., a book index, catalog index in library Indexing

  5. Introduction Indexing: speeds up access to desired data e.g., a book index, catalog index in library DB Indexes: used by DB server to locate tuples in a table Indexes: special tables with ordered tuples one (or more) columns from main table includes pointer to the full row in main file Indexing

  6. Basic Index Operations in MySQL Create on the column most often used in queries, update, delete In MySQL: ALTER TABLE employee ADD INDEX dept_indx (dept_id); Other DB: CREATE INDEX dept_indx ON employee (dept_id); View indexes on a table: SHOW INDEX from employee; Drop an index: ALTER TABLE employee drop INDEX dept_indx; Indexing

  7. Multi-column Indexes Create index on two columns: ALTER TABLE person ADD INDEX name_indx (lname, fname); Can use for queries with: both lname and fname lname alone not for fname alone Indexing

  8. Basic Concepts for Index Implementation SearchKey - attribute to set of attributes used to look up records in a file. An index file consists of records (called index entries) of the form Index files are typically much smaller than the original file Two basic kinds of indices: Ordered indices: search keys are stored in sorted order Hash indices: search keys are distributed using a “hash function” Indexing

  9. Dense Index Files Dense Index : search-key appears for every search-key value from main file Figure: A dense index file Indexing

  10. Sparse Index Files Sparse Index : search-key appears for only a few values Figure: A sparse index file Indexing

  11. B-Tree Indexes Balanced trees: length from root to any leaf is same every non-leaf node has n to n / 2 nodes; n is fixed Most common, default index type Figure: Example of a B-tree Index Indexing

  12. B-tree Indexes Sequential search (without B-tree index): O ( n ) B-tree search: O ( log ( n )) Indexing

  13. B-tree Indexes Sequential search (without B-tree index): O ( n ) B-tree search: O ( log ( n )) Adds: performance overhead (insertion, deletion) adds space overhead Indexing

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend