MySQL index optimization technology

Author: Zen and the Art of Computer Programming

1 Introduction

MySQL index is one of the effective means to improve database query performance. This article will comprehensively describe MySQL index optimization technology in terms of basic knowledge, core concepts, core algorithm principles, specific operation steps, and mathematical formulas.

2. Background introduction

What is an index?

Index is a sorted data structure that helps the database obtain data efficiently. It contains reference pointers to all records in the database table. It is used to quickly locate the disk address corresponding to the data row and speed up retrieval. Indexing is a method of sorting or counting column values ​​in a database table through a certain algorithm to speed up database retrieval. In general, indexes are the best way to improve database query performance.

Why use index?

Indexes can greatly improve the query efficiency of the database. This is because the index file can directly skip unnecessary records and directly locate the required data pages, reducing IO reading time. In addition, indexes can also prevent the system from consuming a lot of memory and reduce the load on the database server. But indexes will also bring additional overhead, such as increased storage space, processing time, etc. Therefore, the more indexes, the better. Only adding indexes when they are suitable for the application scenario and do not affect the query can truly improve the query efficiency of the database.

What scenarios are suitable for indexing?

When the queried column often appears in the WHERE clause or ORDER BY clause, you should consider establishing a corresponding index; if the queried column rarely appears in these locations, there is no need to build an index. Under normal circumstances, the selection of index columns should be based on business characteristics to ensure that the query conditions filter out data that meets the requirements as accurately as possible. In addition, for some frequently used related fields, joint indexes should be established to improve query efficiency.

MySQL index types

MySQL

Guess you like

Origin blog.csdn.net/universsky2015/article/details/132867747