search
HomeDatabaseMysql TutorialWhat does mysql index mean?

What does mysql index mean?

May 31, 2019 pm 03:12 PM
mysql

What is an index?

What does mysql index mean?

MySQL’s official definition of index is: Index (Index) is a data structure that helps MySQL obtain data efficiently. We can simply understand it as: a data structure that can be quickly searched and sorted. Mysql index mainly has two structures: B Tree index and Hash index. The index we usually refer to, unless otherwise specified, generally refers to an index organized in a B-tree structure (B Tree index).

Types of indexes

There are many types of indexes, such as hash, BTREE, full-text index, etc. In fact, no matter what type, they are all for convenience in specific business scenarios. Algorithms for finding data quickly.

For example, hash index, key-value form, the simplest, book table of contents is similar.

If there is a book, we know the title of the article and we need to find this article to read. If there is no table of contents, we have to look through the entire book to find the title.

But if the title is alone Extract it as the key and use the page number as the value to quickly find the content.

Obviously, the table of contents at the beginning of the book takes up several pages, and building an index also consumes resources.

BTREE index is another algorithm, and it will be more efficient to use corresponding indexes in different business scenarios.

Just like the table of contents of Xinhua Dictionary is different from the table of contents of ordinary books, Xinhua Dictionary can quickly find the page on which a word is located through pinyin or radical query methods. This is also a kind of "index"

There are also full-text indexes, etc., which are not described here. For example, you can study the algorithms used by solr and elasticsearch.

Index concept

The essence of index: index is Replication of field values ​​in the database table. This field is called the key of the index.

The index is also a table. This table stores the primary key and index fields and points to the records of the entity table.

Index Often implemented through complex data structures (doubly linked lists, B-trees/B-trees, hashes)

MyISAM storage engine tables support primary indexes, and InnoDB storage engine tables support clustered indexes (primary indexes) and non-clustered indexes. Cluster index (auxiliary index) index optimization uses

Advantages and disadvantages of index

@Advantages:

The establishment of MySQL index is for the efficient operation of MySQL It is very important and can greatly improve the retrieval speed of MySQL.

Data retrieval in grouping and sorting clauses can reduce the time spent in grouping and sorting in query time (database records will be reordered)

The connection conditions of table connections can be accelerated Tables are directly connected to tables

@Disadvantages:

But excessive use of indexes will cause index abuse, increase the retrieval speed, and reduce the update speed of the table

For example : When adding, deleting, modifying, and querying the table, MySQL must not only save the data, but also save the index file. Creating the index will occupy the disk space of the index file

It will take time to create and maintain the index, as the data Increase with the increase in quantity

The above is the detailed content of What does mysql index mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL String Types: Storage, Performance, and Best PracticesMySQL String Types: Storage, Performance, and Best PracticesMay 10, 2025 am 12:02 AM

MySQLstringtypesimpactstorageandperformanceasfollows:1)CHARisfixed-length,alwaysusingthesamestoragespace,whichcanbefasterbutlessspace-efficient.2)VARCHARisvariable-length,morespace-efficientbutpotentiallyslower.3)TEXTisforlargetext,storedoutsiderows,

Understanding MySQL String Types: VARCHAR, TEXT, CHAR, and MoreUnderstanding MySQL String Types: VARCHAR, TEXT, CHAR, and MoreMay 10, 2025 am 12:02 AM

MySQLstringtypesincludeVARCHAR,TEXT,CHAR,ENUM,andSET.1)VARCHARisversatileforvariable-lengthstringsuptoaspecifiedlimit.2)TEXTisidealforlargetextstoragewithoutadefinedlength.3)CHARisfixed-length,suitableforconsistentdatalikecodes.4)ENUMenforcesdatainte

What are the String Data Types in MySQL?What are the String Data Types in MySQL?May 10, 2025 am 12:01 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function