MySql Index Index advantages 1. You can ensure the uniqueness of the data by creating a unique index or primary key index. Index Disadvantages 1. Creating and maintaining indexes takes time, which increases with the amount of data. (Creating an index will take up disk space for the index file. Generally this problem is not too serious, but if you create multiple combined indexes on a large table, the index file will expand quickly). Things to note when using indexes 1. Speed up indexing on columns that are frequently searched 6. If you create an index for the nickname field in the like statement, the index will not work when the query statement is nickname lick '%ABC%'. However, the index will work if the query statement is nickname lick 'ABC%'. 7. The index will not include NULL columns. If a column contains NULL values, it will not be included in the index. If a column in a composite index contains NULL values, the composite index will be invalid. Generally, a default value of 0 or ' ' string is required. 8. Use short indexes. If one of your fields is Char(32) or int(32), specify a prefix length when creating the index, such as the first 10 characters (assuming that most values are unique). Then short indexes can increase query speed, save disk space, and reduce I/O operations. 9. Do not perform operations on columns, as this will invalidate the MySQL index and perform a full table scan 10. Choose the smaller the data type, the better, because usually the smaller the data type, the smaller the space occupied in the disk, memory, CPU, cache, and the faster the processing. When not to create an index 1. Columns that are rarely used in queries should not be indexed. If indexes are created, however, MySQL performance will be reduced and space requirements will increase. The above is the detailed analysis of MySql index usage strategy. For more information about MySQL index, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Docker data volume common operation code examples
>>: JavaScript to achieve a simple magnifying glass effect
This article example shares the specific code of ...
1. Introduction to Distributed Storage System Wit...
With a lot of CSS experience as a web designer, we...
For security reasons, MySql-Server only allows th...
In daily work, we may encounter a layout like thi...
CSS import method - inline Through the style tag ...
Demand background The project is made using Vue, ...
This article introduces the characteristics of CS...
An at-rule is a declaration that provides instruc...
Preface You may often receive warning emails from...
Types of joins 1. Inner join: The fields in the t...
Seurat is a heavyweight R package for single-cell...
[LeetCode] 183.Customers Who Never Order Suppose ...
Effect (source code at the end): accomplish: 1. D...
Recently, our small team needs to share a shared ...