{"id":6130,"date":"2023-07-26T09:54:32","date_gmt":"2023-07-26T09:54:32","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=6130"},"modified":"2023-07-26T09:54:35","modified_gmt":"2023-07-26T09:54:35","slug":"how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/","title":{"rendered":"How to use Indexes in MySQL in Linux"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en.jpg\" alt=\"Indexes in MySQL in ubuntu centos Debian Redhat\" class=\"wp-image-6155\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction-to-indexes\">Introduction to Indexes<\/h2>\n\n\n\n<p>Indexes are an important part of optimizing MySQL databases. An index allows the database to find and retrieve data from tables much faster by storing a sorted list of values that point back to the full records.<\/p>\n\n\n\n<p>Without an index, MySQL must scan through every row of a table to find relevant data. This can become very slow as tables grow larger. Adding proper indexes allows MySQL to navigate the table data much more efficiently.<\/p>\n\n\n\n<p>Some key benefits of using indexes include:<\/p>\n\n\n\n<ul>\n<li>Faster lookups for specific rows and values<\/li>\n\n\n\n<li>Improved performance of various queries, especially JOINs and WHERE clauses<\/li>\n\n\n\n<li>Ability to optimize data retrieval across large database tables<\/li>\n\n\n\n<li>Faster sorting and grouping operations on indexed columns<\/li>\n<\/ul>\n\n\n\n<p>MySQL supports several index types to improve queries in different ways:<\/p>\n\n\n\n<ul>\n<li>NORMAL \u2013 Basic index on single or multiple columns<\/li>\n\n\n\n<li>UNIQUE \u2013 Ensures uniqueness of indexed values<\/li>\n\n\n\n<li>FULLTEXT &#8211; For optimizing text-based searches<\/li>\n\n\n\n<li>SPATIAL &#8211; For spatial data like locations<\/li>\n<\/ul>\n\n\n\n<p>This guide will provide examples of creating and using these different MySQL index types to improve database performance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"connecting-to-mysql-and-setting-up-a-sample-database\">Connecting to MySQL and Setting up a Sample Database<\/h2>\n\n\n\n<p>Before demonstrating indexes, we need a MySQL database with some sample data. Here are the steps to connect to MySQL and create a simple &#8220;contacts&#8221; database:<\/p>\n\n\n\n<ol>\n<li>Connect to the MySQL server from the command line with the mysql client:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ mysql -u root -p<\/code><\/pre>\n\n\n\n<ol start=\"2\">\n<li>When prompted, enter the password for the root MySQL user. You should now be at the MySQL monitor.<\/li>\n\n\n\n<li>Create a new database called&nbsp;<code>contacts<\/code>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; CREATE DATABASE contacts;<\/code><\/pre>\n\n\n\n<ol start=\"4\">\n<li>Switch to the new contacts database:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; USE contacts;<\/code><\/pre>\n\n\n\n<ol start=\"5\">\n<li>Create a&nbsp;<code>contacts<\/code>&nbsp;table with some sample data:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; CREATE TABLE contacts (\n  id INT AUTO_INCREMENT PRIMARY KEY,\n  first_name VARCHAR(50),\n  last_name VARCHAR(50),\n  email VARCHAR(100),\n  phone VARCHAR(20)\n);\n\nmysql&gt; INSERT INTO contacts (first_name, last_name, email, phone) \nVALUES\n  ('John', 'Doe', 'john@example.com', '555-555-5555'),\n  ('Jane', 'Doe', 'jane@example.com', '555-555-5556'),\n  ('Bob', 'Smith', 'bob@example.com', '555-555-5557');<\/code><\/pre>\n\n\n\n<p>This creates a simple table to store contact information like name, email, and phone number.<\/p>\n\n\n\n<p>We can confirm it worked by querying the table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; SELECT * FROM contacts;<\/code><\/pre>\n\n\n\n<p>This should display the sample data we inserted. Now we have a database and table ready to demonstrate using indexes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">+----+------------+-----------+--------------------+---------------+\n| id | first_name | last_name | email              | phone         |\n+----+------------+-----------+--------------------+---------------+   \n|  1 | John       | Doe       | john@example.com   | 555-555-5555  |\n|  2 | Jane       | Doe       | jane@example.com   | 555-555-5556  |\n|  3 | Bob        | Smith     | bob@example.com    | 555-555-5557  |\n+----+------------+-----------+--------------------+---------------+\n3 lignes trouv\u00e9es (0.00 sec)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-single-column-indexes\">Using Single-Column Indexes<\/h2>\n\n\n\n<p>A standard index in MySQL indexes one column of a database table. This allows fast lookups and sorts on that particular column.<\/p>\n\n\n\n<p>To add an index to a column, we can use the&nbsp;<code>CREATE INDEX<\/code>&nbsp;statement:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; CREATE INDEX idx_last_name ON contacts(last_name);<\/code><\/pre>\n\n\n\n<p>This adds an index named&nbsp;<code>idx_last_name<\/code>&nbsp;on the&nbsp;<code>last_name<\/code>&nbsp;column of the&nbsp;<code>contacts<\/code>&nbsp;table.<\/p>\n\n\n\n<p>Indexing the last name column can optimize queries like this that filter by a last name:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; SELECT * FROM contacts WHERE last_name='Doe';<\/code><\/pre>\n\n\n\n<p>Instead of scanning every row, MySQL can quickly lookup the indexed last_name column to find relevant rows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><code>+<em>----+------------+-----------+--------------------+---------------+<\/em>\n| id | first_name | last_name | email              | phone         |\n+<em>----+------------+-----------+--------------------+---------------+<\/em>\n|  1 | John       | Doe       | john@example.com   | 555-555-5555  |\n|  2 | Jane       | Doe       | jane@example.com   | 555-555-5556  |\n+<em>----+------------+-----------+--------------------+---------------+<\/em>\n2 rows in set (0.00 sec)<\/code><\/code><\/pre>\n\n\n\n<p>This shows the rows returned from the contacts table where the last name is &#8216;Doe&#8217;. The index on the last_name column allows this query to run quickly without scanning the entire table.<\/p>\n\n\n\n<p>We can add similar indexes on other table columns like email or phone:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; CREATE INDEX idx_email ON contacts(email);\nmysql&gt; CREATE INDEX idx_phone ON contacts(phone); <\/code><\/pre>\n\n\n\n<p>This allows fast lookups by those columns too.<\/p>\n\n\n\n<p>To delete an index when no longer needed, use&nbsp;<code>DROP INDEX<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; DROP INDEX idx_email ON contacts;<\/code><\/pre>\n\n\n\n<p>Single-column indexes work best on columns frequently used for lookups and joins. Don&#8217;t over-index all columns, as indexes take up storage space and slow write operations like INSERT and UPDATE as the indexes also must be updated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-unique-indexes-to-prevent-data-duplication\">Using Unique Indexes to Prevent Data Duplication<\/h2>\n\n\n\n<p>In many cases, we want to prevent duplicate values from being stored in certain columns, such as email addresses or usernames. MySQL provides a special UNIQUE index that enforces this constraint:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; CREATE UNIQUE INDEX idx_email ON contacts(email);<\/code><\/pre>\n\n\n\n<p>This index only allows unique email values to be inserted into that column. If we try to insert a duplicate email:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; INSERT INTO contacts (first_name, last_name, email, phone)\nVALUES ('Bob', 'Jones', 'bob@example.com', '555-555-5558'); <\/code><\/pre>\n\n\n\n<p>We would get an error:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">ERROR 1062 (23000): Duplicate entry 'bob@example.com' for key 'idx_email'<\/code><\/pre>\n\n\n\n<p>The unique index prevented inserting the duplicate email. This helps enforce data integrity in important columns.<\/p>\n\n\n\n<p>Like other indexes, the UNIQUE index still provides fast lookups by the indexed column. The uniqueness is just an added constraint.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-indexes-on-multiple-columns\">Using Indexes on Multiple Columns<\/h2>\n\n\n\n<p>Indexes can also be created that span multiple columns. This allows optimizing queries that filter on those columns in the same order.<\/p>\n\n\n\n<p>For example, to index both first and last name columns:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; CREATE INDEX idx_name ON contacts(first_name, last_name);<\/code><\/pre>\n\n\n\n<p>This can optimize a query with a WHERE clause on both columns:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; SELECT * FROM contacts WHERE first_name='Jane'AND last_name='Doe';<\/code><\/pre>\n\n\n\n<p>It also works for queries filtering just the first column:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; SELECT * FROM contacts WHERE first_name='Jane';<\/code><\/pre>\n\n\n\n<p>But it would not optimize a query filtering only on the second indexed column:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; SELECT * FROM contacts WHERE last_name='Doe';<\/code><\/pre>\n\n\n\n<p>In that case the single-column index on&nbsp;<code>last_name<\/code>&nbsp;would be used instead.<\/p>\n\n\n\n<p>The order of columns in a multiple-column index matters. The optimizations apply to WHERE clauses with filters on prefixes of the index columns.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"listing-and-removing-existing-indexes\">Listing and Removing Existing Indexes<\/h2>\n\n\n\n<p>To help understand what indexes exist on a table, we can query the&nbsp;<code>INFORMATION_SCHEMA<\/code>&nbsp;system database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA ='contacts'AND TABLE_NAME ='contacts';<\/code><\/pre>\n\n\n\n<p>This would display metadata about the indexes on our table, including their names and columns.&nbsp;<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">+------+------------+------------+------------+--------------+-------------+----------+------------+----------+--------+------+------------+---------+---------------+\n| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | NON_UNIQUE | INDEX_SCHEMA | INDEX_NAME | SEQ_IN_INDEX | COLUMN_NAME | COLLATION | CARDINALITY | SUB_PART | PACKED | NULLABLE | INDEX_TYPE | COMMENT |\n+------+------------+------------+------------+--------------+-------------+----------+------------+----------+--------+------+------------+---------+---------------+\n| def  | contacts   | contacts   |          0 | contacts     | PRIMARY     |            1 | id         | A        |           3 |     NULL | NULL   |         | BTREE      |         |  \n| def  | contacts   | contacts   |          1 | contacts     | idx_email   |            1 | email      | A        |           3 |     NULL | NULL   | YES    | BTREE      |         |\n+------+------------+------------+------------+--------------+-------------+----------+------------+----------+--------+------+------------+---------+---------------+<\/code><\/pre>\n\n\n\n<p>When an index is no longer needed, we can remove it with&nbsp;<code>DROP INDEX<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt; DROP INDEX idx_name ON contacts;<\/code><\/pre>\n\n\n\n<p>Dropping indexes that are not optimized and regularly used can help improve write performance and reduce storage requirements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Adding indexes provides powerful optimizations for querying and manipulating data in MySQL tables. The right indexes can greatly speed up lookups, filters, sorting and joins.<\/p>\n\n\n\n<p>Some key points to remember:<\/p>\n\n\n\n<ul>\n<li>Use single-column indexes for frequently filtered columns<\/li>\n\n\n\n<li>UNIQUE indexes prevent duplicate entries in a column<\/li>\n\n\n\n<li>Multiple-column indexes optimize queries filtering on those columns in order<\/li>\n\n\n\n<li>Don&#8217;t over-index! Evaluate query needs and drops indexes that aren&#8217;t used.<\/li>\n<\/ul>\n\n\n\n<p>Properly leveraging indexes is crucial for optimal MySQL database performance, especially as data grows larger. Take time to understand indexing tradeoffs and best practices when designing your database schema and queries.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Indexes Indexes are an important part of optimizing MySQL databases. An index allows the database to find and retrieve data from tables much faster by storing a sorted list of values that point back to the full records. Without an index, MySQL must scan through every row of a table to find relevant ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[57,69],"tags":[],"yoast_head":"\n<title>How to use Indexes in MySQL in Linux - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Learn how to use indexes in MySQL including single-column, unique, and multi-column indexes. Improve MySQL query speed with proper indexing.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use Indexes in MySQL in Linux - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Learn how to use indexes in MySQL including single-column, unique, and multi-column indexes. Improve MySQL query speed with proper indexing.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-26T09:54:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-26T09:54:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"How to use Indexes in MySQL in Linux\",\"datePublished\":\"2023-07-26T09:54:32+00:00\",\"dateModified\":\"2023-07-26T09:54:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\"},\"wordCount\":884,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"Databases\",\"Linux system administration\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\",\"name\":\"How to use Indexes in MySQL in Linux - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2023-07-26T09:54:32+00:00\",\"dateModified\":\"2023-07-26T09:54:35+00:00\",\"description\":\"Learn how to use indexes in MySQL including single-column, unique, and multi-column indexes. Improve MySQL query speed with proper indexing.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use Indexes in MySQL in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"How to use Indexes in MySQL in Linux - WebHi Tutorials &amp; Documentations","description":"Learn how to use indexes in MySQL including single-column, unique, and multi-column indexes. Improve MySQL query speed with proper indexing.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/","og_locale":"en_US","og_type":"article","og_title":"How to use Indexes in MySQL in Linux - WebHi Tutorials &amp; Documentations","og_description":"Learn how to use indexes in MySQL including single-column, unique, and multi-column indexes. Improve MySQL query speed with proper indexing.","og_url":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2023-07-26T09:54:32+00:00","article_modified_time":"2023-07-26T09:54:35+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/07\/mysql_index_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"How to use Indexes in MySQL in Linux","datePublished":"2023-07-26T09:54:32+00:00","dateModified":"2023-07-26T09:54:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/"},"wordCount":884,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["Databases","Linux system administration"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/","url":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/","name":"How to use Indexes in MySQL in Linux - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2023-07-26T09:54:32+00:00","dateModified":"2023-07-26T09:54:35+00:00","description":"Learn how to use indexes in MySQL including single-column, unique, and multi-column indexes. Improve MySQL query speed with proper indexing.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-indexes-in-mysql-in-linux-ubuntu-centos-debian-redhat\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"How to use Indexes in MySQL in Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/6130"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=6130"}],"version-history":[{"count":18,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/6130\/revisions"}],"predecessor-version":[{"id":6184,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/6130\/revisions\/6184"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=6130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=6130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=6130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}