18
1 © Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018 17 Other indexing techniques 28/2/18 9:14:09 pm Other indexing techniques

Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

Embed Size (px)

Citation preview

Page 1: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

1© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Other indexing techniques

Page 2: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

2© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Subtypes of B*Tree index

Index organized tableIndex organized table is a relational table stored in a index structure; index key is equal to schema of a relational table

B*tree cluster indexCluster index is a B*Tree index created over a cluster key; index key "points" to the first block in a sequence of blocks that contain the rows with the same cluster key

Compressed key indexCompressed key index is a B*Tree index with redundancies eliminated from composite keys

Page 3: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

3© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Descending indexDescending index is a B*Tree index that has keys sorted at leaf level of the index in descending order

Reverse key indexReverse key index is a B*Tree index where the bytes in an index key are reversed

Subtypes of B*Tree index

Page 4: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

4© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Compressed key index

CREATE INDEX ORDERS_CIDX ON ORDERS(O_CUSTKEY, O_ORDERSTATUS, O_TOTALPRICE)COMPRESS 1;

Every key consists of "prefix" and "suffix" component

"Prefix" is built on the leading columns of concatenated index (O_CUSTKEY) and has many repeated values

"Suffix" is built on the trailing columns of concatenated index (O_ORDERSTATUS, O_TOTALPRICE) and it is unique component of an index key

The repeated "prefixes" are replaced with one prefix and 4 bytes to mark end of prefix group

Incorrectly compressed index can be larger than original

Page 5: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

5© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

STUDENT

s# = 9865432

Index organized table

Index organized table is a relational table stored in a B*Tree structure; Index organized table is transparent to database applications, i.e. it is visible to database applications as a regular relational table

Page 6: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

6© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

CREATE TABLE REGION(R_NAME CHAR(25) NOT NULL,

CONSTRAINT REGION_PKEY PRIMARY KEY(R_NAME) ) ORGANIZATION INDEX;

Index organized table is recommended when a primary key is composite and an average length of the key is not significantly shorter than average row lengthA perfect candidate for index organized table is a lookup relational tableIndex organized table is also recommended when it is necessary to enforce co-location of data or data should be stored in a specific order

Index organized table

Page 7: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

7© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm28/2/18 9:13:16 pm

B*Tree cluster index

CREATE INDEX COUNTRY_IDX ON CLUSTER COUNTRY_CLST;

B*Tree cluster index must be created on a cluster key

The other storage organization for cluster index is hash cluster indexThe keys at leaf level of B*Tree cluster index are associated with row identifiers "pointing" to the blocks that contain the rows from one or more relational tables

B*Tree cluster index cannot be created without a cluster

Page 8: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

8© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Descending index

Descending B*Tree index allows to sort composite keys in ascending order for some attributes and in descending order for the others

CREATE INDEX ORDERS_DESIDX ON ORDERS(O_CUSTKEY DESC, O_ORDERSTATUS ASC);

Descending B*Tree index eliminates the needs for sorting in any order of the attributes; leaf level of an index is already sorted

Page 9: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

9© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Reverse key index

CREATE INDEX ORDERS_CIDX ON ORDERS(O_CUSTKEY, O_ORDERSTATUS) REVERSE;

Reverse key index reduces the total number of concurrent transactions attempting to access the same data block when operating on adjacent index keysReverse index key is recommended when an indexed attribute is populated from a sequence or timestamp

Reverse key index automatically reverse the order of bytes in the key value stored in the indexFor example if the value of indexed attribute is 'ABCD' then the value of the key on reverse index is 'DCBA'

Page 10: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

10© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Non B*Tree indexes

Bitmap join indexBitmap join index is a bitmap index that allows for denormalization in an index structure instead of in a table

Function based indexFunction based index is a B*Tree or bitmap index that stores the computed result of a function on a row's columns and not the column data itself

Bitmap indexBitmap index is an index where each value of a key is associated with a bitmap "pointing" simultaneously to all rows that have the given value of a key

Page 11: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

11© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Hash cluster indexHash cluster index is a hash index created over a cluster key; index key "points" to the first block in a sequence of blocks that contain the rows with the same value of hashed cluster key

Application domain indexApplication domain index is an index built by a user

Non B*Tree indexes

Page 12: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

12© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

P# Colour Weight1 green 96.13 red 124.44 red 100.85 blue 60.26 red 56.4… … …

ROWID12356543287210011003…

Colour = blue 0 0 0 1 0 …Colour = green 1 0 0 0 0 …Colour = red 0 1 1 0 1 ……

ROWID 1235 6543 2872 1001 1003 …

Bitmap index

Bitmap index is appropriate for highly repetitive data, i.e data with few distinct values relative to the total number of rows in a relational table

Page 13: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

13© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Bitmap indexes are designed for data warehousing and ad hoc query environments where a full set of queries that may be asked is not known at system implementation time

CREATE BITMAP INDEX PART_BIDX ON PART(P_NAME);

Bitmap indexes are well suited for read-intensive environments and not well suited for write-intensive environments

Bitmap index

Page 14: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

14© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Bitmap join index

In bitmap join index the keys from a column in one relational table are associated with the rows identifiers "pointing" to the rows in another relational table

CREATE BITMAP INDEX EMP_JIDX ON EMP(D.DNAME)FROM EMP E, DEPT DWHERE E.DEPTNO = D.DEPTNO;

For example, the values of DNAME attribute in a relational table DEPT are associated with the row identifier "pointing" to the rows in a relational table EMPJoin condition in bitmap index specification must join to a primary or unique key in the other table

Page 15: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

15© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Function-based index is like a standard B*-tree index, the index is based on the result of SQL function, rather than on the value of an attribute An ordinary index cannot be applied if a function is applied to the indexed attribute, e.g.

SELECT * FROM Part WHERE UPPER(Colour) = 'RED';

Function-based index based on UPPER function solves the problem

Function based index

Page 16: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

16© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

P# Colour Weight1 GREEN 96.13 red 124.44 Red 100.85 blue 60.26 RED 56.4…

UPPER(Colour)

BLUE GREEN RED

SELECT * FROM Part WHERE UPPER(Colour) = 'RED';

Function based index

Page 17: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

17© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:09 pm

Hash cluster index

CREATE CLUSTER DATE_HCLST(ODATE DATE ) HASHKEYS 100000SIZE 400STORAGE (INITIAL 10M NEXT 5M PCTINCREASE 0)PCTFREE 0;

Hash cluster index must be created on a cluster keyHash cluster index cannot be created without a cluster

Page 18: Other indexingjrg/317/SLIDES/17Otherindexing...Subtypes of B*Tree index Index organized table Index organized table is a relational table stored in a index structure; index key is

18© Janusz R. Getta CSCI317 Database Performance Tuning, SCIT, Autumn 2018

17 Other indexing techniques 28/2/18 9:14:10 pm

References

Ramakrishnan R., J. Gehrke Database Management Systems, chapter 25http://www.uow.edu.au/~jrg/315/HOWTO12 How to use other types of indexes ?