Database optimization tutorial (7) cost and cost of INDEX OPTIMIZATION

Source: Internet
Author: User

Database optimization tutorial (7) cost and cost of INDEX OPTIMIZATION
Iii. Index

4. index cost

The previous sections introduced the power of indexes in improving performance and how to use indexes. However, indexes also have overhead.

1) disk space occupied

As described above, indexing is costly, as the. ibd file (innodb engine) or. myi file (myisam engine) increases after an index is added.


2) Slow dml operations

After an index is added, it is faster because the table sorts the data based on the index according to a certain algorithm (Binary Tree, etc.). Therefore, the binary tree needs to be re-sorted after deletion, addition, and insertion, resulting in lower execution efficiency.

 

In this case, it depends on whether your database runs many dml statements or more dql statements.

Use the following statement to query

 

Queries the total number of select executions

[Plain]View plaincopy
  1. Show status like 'com _ select'

Queries the total number of insert operations performed

[Plain]View plaincopy
  1. Show status like 'com _ insert'

And so on

 

In general, dql statements operate much more than dml statements! Close

 

Since indexing has advantages and disadvantages, how can we artificially control the use of indexing?

Disable Indexing

[Plain]View plaincopy
  1. Select xxx from table ignore index (index_xxx)

Use index forcibly

[Plain]View plaincopy
  1. Select * from table force index (index_xxx)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.