0% found this document useful (0 votes)
17 views

Indexing The Mysql 5.1: Performance Enhancement

The document discusses indexing in MySQL databases. It begins with defining what an index is, explaining that indexes help optimize query performance. It then covers the different types of indexes in MySQL, including hash indexes, B-tree indexes, full-text indexes, and spatial indexes. The document also discusses when to use indexes, such as for columns frequently used in where clauses, and when not to use them, like for low-cardinality columns. It concludes with recommendations around choosing appropriate indexes and locations to place indexes for best performance.

Uploaded by

api-320519693
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)
17 views

Indexing The Mysql 5.1: Performance Enhancement

The document discusses indexing in MySQL databases. It begins with defining what an index is, explaining that indexes help optimize query performance. It then covers the different types of indexes in MySQL, including hash indexes, B-tree indexes, full-text indexes, and spatial indexes. The document also discusses when to use indexes, such as for columns frequently used in where clauses, and when not to use them, like for low-cardinality columns. It concludes with recommendations around choosing appropriate indexes and locations to place indexes for best performance.

Uploaded by

api-320519693
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