0% found this document useful (0 votes)
39 views39 pages

Indexing The Mysql 5.1: Performance Enhancement

This document discusses indexing in MySQL databases. It begins with an introduction to indexes, explaining what they are, why they are used, and the main types of indexes including hash, B-tree, full-text and R-tree indexes. It then covers considerations for when to use and not use indexes such as with the EXPLAIN statement. The document also outlines the different types of indexes like single column, concatenated, covering and partial indexes. It concludes with sections on where to add indexes and how to choose appropriate indexes for databases.

Uploaded by

api-320520004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views39 pages

Indexing The Mysql 5.1: Performance Enhancement

This document discusses indexing in MySQL databases. It begins with an introduction to indexes, explaining what they are, why they are used, and the main types of indexes including hash, B-tree, full-text and R-tree indexes. It then covers considerations for when to use and not use indexes such as with the EXPLAIN statement. The document also outlines the different types of indexes like single column, concatenated, covering and partial indexes. It concludes with sections on where to add indexes and how to choose appropriate indexes for databases.

Uploaded by

api-320520004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Indexing the MySQL 5.

1
Performance Enhancement

HoaND - NamNV

MySQL Architecture

Agenda
1.
2.
3.
4.
5.
6.
7.

What is Index?
Why is index?
How is index ?
When using index or not ?
Type of index
Where add index
Choosing indexes

1.What is Index?

2.Why is index ?

3.How is index ?

3.How is index ?
EMPLOYEE
ID

FIRSTNAM
E

LASTNAME AGE

SALARY

GENDER

001

Ashish

Kataria

25

10000

002

Rony

Felix

28

20000

003

Namita

Misra

24

10000

004

Ankur

Aeran

30

25000

005

Priyanka

Jain

30

20000

006

Pradeep

Pandey

31

30000

007

Pankaj

Gupta

25

12000

008

Ankit

Garg

30

15000

Hash Index
Hash index supported only by
Memory Storage Engine.

B-Tree Index

B-Tree Index
00
1

00
2

00
3

00
6

00
4

00
5

00
8

00
7

EMPLOYEE FIRSTNAM LASTNAM


ID
E
E

AG
E

SALAR
Y

GENDER

001

Ashish

Kataria

25

10000

002

Rony

Felix

28

20000

003

Namita

Misra

24

10000

004

Ankur

Aeran

30

25000

005

Priyanka

Jain

30

20000

006

Pradeep

Pandey

31

30000

007

Pankaj

Gupta

25

12000

008

Ankit

Garg

30

15000

B-Tree Index

Full-text Index

R-Tree Index
Spacial index is supported by only
MyISAM storage engine. Its just like
B-tree but the index follow any order
not just left to right. This index used
for only specific purpose. (I.e MySQL
GIS functions)

3.How is index?

4.When use index ?

4.When use index ?


-EXPLAIN
Explain SQL:
select_type
simple, primary, subquery, derived, union
type
all < index < range < ref < eq_ref < const
system < null
using where
using index
using filesort
using temporary

4.When use index ?


-EXPLAIN

4.When use index ?


-EXPLAIN

4.When use index ?


-EXPLAIN

4.When use index ?


-EXPLAIN

4.When use index ?


EXPLAIN-TYPE

4.When use index ?


EXPLAIN-TYPE

4.When use index ?


for these operations

MySQL uses indexes

4.When use index ?

http://www.mysqlperformanceblog.com/2009/09/12/3-waysmysql-uses-indexes/

4.When use index ?

4.When not use index ?

4.When not use index ?

5.Type of index?

5.Type Single column


index

http://dev.mysql.com/doc/refman/5.0/en/column-indexes.html

5.Type Concatenated
Index

http://dev.mysql.com/doc/refman/5.0/en/multiple-columnindexes.html

5.Type Covering Index

http://www.mysqlperformanceblog.com/2006/11/23/coveringindex-and-prefix-indexes/

5.Type Partial Index

http://ronaldbradford.com/blog/tag/partial-index/

5.Type Clusteredvs.Non
clustered

http://rajeshstutorials.blogspot.com/2012/02/clustered-indexesvs-non-clustered.html

6.Where add index ?

6.Where add index ?

6.Where - MyISAM
Fortablesareusedmoreoften Key
Cache can be used to optimize read
of those tables
hot_cache.key_buffer_size=128K
Assigntablestocaches
CACHEINDEX table1,TOhot_cache;
CACHEINDEXtable2TOcold_cache;

7.Choosing Indexes

7.Choosing Indexes

QUESTIONS & ANSWERS

You might also like