- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Best practices for using MySQL indexes?
A database index is a data structure that improves the speed of operations in a table. Indexes can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records.
The best practices for using MySQL indexes are.
If a table is very large as a CSV, then using indexes will insert the records at the end.
The indexes create a sequence of rows of a table.
Indexes speed up certain select operations
The INSERT and UPDATE statements take more time on tables having indexes, whereas the SELECT statements become fast on those tables. The reason is that while doing insert or update, a database needs to insert or update the index values as well.
Example of MySQL indexes: If a CSV file is spread out, then indexes maintain the ordering of rows.
Let us see an example to create an index.
Create a table and indexes on a specific column.
mysql> create table IndexingDemo -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.86 sec)
The syntax to create an index on a table.
create index yourIndexName on yourTableName(column_name);
The following is the output.
mysql> create index indexName on IndexingDemo(Name); Query OK, 0 rows affected (0.75 sec) Records: 0 Duplicates: 0 Warnings: 0
- Related Articles
- Best practices for Java comments.
- What are the best practices for using loops in Python?
- Best practices for writing a Dockerfile
- What are the best practices for using if statements in Python?
- What are the “best practices” for using import in a Python module?
- Best Practices For Preparing a Lessons Learned Document
- Openssh security best practices
- Acquiring Resources – Best Practices!
- VMware vSphere Best Practices
- What are the best practices for committing in Git?
- What are the best practices for function overloading in JavaScript?
- What are the best practices for exception handling in Python?
- C# Exception Handling Best Practices
- Java variable declaration best practices
- Nginx WebServer Best Security Practices
