Download presentation
Presentation is loading. Please wait.
1
March 2010ACS-4904 Ron McFadyen1 Indexes B-tree index Bitmapped index Bitmapped join index A data warehousing DBMS will likely provide these, or variations, on these All DBMSs provide variations of b-trees for indexing See http://en.wikipedia.org/wiki/Bitmap_index http://www.dba-oracle.com/oracle_tips_bitmapped_indexes.htm http://www.oracle.com/technology/pub/articles/sharma_indexes.html
2
March 2010ACS-4904 Ron McFadyen2 B-tree structures Most used access structure in database systems. There are b-trees, b+-trees, b*-trees, etc. B-trees and their variations are: balanced very good in environments with mixed reading and writing operations, concurrency, exact searches and range searches provide excellent performance when used to find a few rows in big tables are studied in ACS-3902
3
March 2010ACS-4904 Ron McFadyen3 Bitmapped index Consider the following Customer table Cust_idgenderprovincephone 22MAb(403) 444-1234 44MMb(204) 777-6789 77FSk(306) 384-8474 88FSk(306) 384-6721 99MMb(204) 456-1234 Province: Mb … rows 2, 5 Sk … rows 3, 4 Ab … row 1 Gender: M … rows 1, 2, 5 F … rows 3, 4
4
March 2010ACS-4904 Ron McFadyen4 Bitmapped index Suppose for a relation R the cardinality of attribute A is c and so we can represent the values existing for A as a 1, a 2, … a c Then, if we have a bitmap index for R on attribute A there are c bit arrays, b 1, b 2, … b c, one for each value of attribute A: b i is the bit array corresponding to value a i Consider b k if the i th row of R contains the value a K for attribute A, then the i th bit of b k is 1 otherwise the i th bit of b k is 0
5
March 2010ACS-4904 Ron McFadyen5 Bitmapped index If we construct a bitmapped index for Customer on Gender we would have two bit arrays of 5 bits each: m 1 1 0 0 1 f 0 0 1 1 0
6
March 2010ACS-4904 Ron McFadyen6 Bitmapped index If we construct a bitmapped index for Customer on Province we would have three bit arrays of 5 bits each: Ab 1 0 0 0 0 Mb 0 1 0 0 1 Sk..... What values appear in this vector?
7
March 2010ACS-4904 Ron McFadyen7 Bitmapped index Consider a query Select Customer.name, Sum(s.amount) From Sales s Inner Join Customer c On ( … ) where c.gender =M and c.province = Mb Group by Customer.name How could the query optimizer utilize bit map indexes?
8
March 2010ACS-4904 Ron McFadyen8 Bitmapped index A query tree for Select Customer.name, Sum(s.amount) From Sales s Inner Join Customer c On ( … ) where c.gender =M and c.province = Mb Group by Customer.name Sort (to prepare for grouping) groups and sums ( to report name and sum) Join (inner join of left and right subtree) Selection (determine pertinent rows of Customer) Customer Relation Sales Relation
9
March 2010ACS-4904 Ron McFadyen9 Bitmapped index Consider the where clause that selects rows of Customer c.gender =M and c.province = Mb By anding the two bit arrays for gender=M and province=Mb, the dbms knows which rows of Customer to join to Sales In our case, two rows of Customer are involved instead of the whole Customer table. Mb 0 1 0 0 1 0 1 0 0 1 M 1 1 0 0 1 “and”
10
March 2010ACS-4904 Ron McFadyen10 Bitmapped Join Index In general, a join index is a structure containing index entries (attribute value, row pointers), where the attribute values are in one table, and the row pointers are to related rows in another table Consider DateSales Customer
11
March 2010ACS-4904 Ron McFadyen11 Join Index Cust_idgenderprovincephone 22MAb(403) 444-1234 44MMb(204) 777-6789 77FSk(306) 384-8474 88FSk(306) 384-6721 99MMb(204) 456-1234 Cust_idStore_idDate_idAmount 22190100 4427150 2223350 4435550 1 2 3 4 9935525 5 row Sales Customer
12
March 2010ACS-4904 Ron McFadyen12 Bitmapped Join Index In some database systems, a bitmapped join index can be created which indexes Sales using an attribute of Customer: home province. Here is an SQL statement to create the index: CREATE BITMAP INDEX cust_sales_bji ON Sales(Customer.province) FROM Sales, Customer WHERE Sales.cust_id = Customer.cust_id;
13
March 2010ACS-4904 Ron McFadyen13 Bitmapped Join Index There are three province values in Customer. The join index will have three entries where each has a province value and a bitmap: Mb0 1 0 1 1 Ab1 0 1 0 0 Sk0 0 0 0 0 The bitmap join index shows that rows 2, 4, 5 of the Sales fact table are rows for customers with province = Mb The bitmap join index shows that rows 1, 3 of the Sales fact table are rows for customers with province = Ab The bitmap join index shows that no rows of the Sales fact table are rows for customers with province = Sk
14
March 2010ACS-4904 Ron McFadyen14 Bitmapped Join Index A bitmap join index could be used to evaluate the following query. In this query, the CUSTOMER table will not even be accessed; the query is executed using only the bitmap join index and the Sales table. SELECT SUM(Sales.dollar_amount) FROM Sales, Customer WHERE Sales.cust_id = Customer.cust_id AND Customer.province = Mb; The bitmap index will show that rows 2, 4, 5 of the Sales fact table are rows for customers with province = Mb
15
March 2010ACS-4904 Ron McFadyen15 Bitmapped Join Index http://www.intelligententerprise.com/000929/feat1.jhtml mentions star joins available in UDB and Oracle
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.