EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials MySQL Tutorial MySQL Performance Tuning
Secondary Sidebar
MySQL Tutorial
  • Advanced
    • MySQL Formatter
    • MySQL TINYINT
    • MySQL Grant All Privileges
    • MySQL DROP TABLE
    • MySQL rename database
    • MySQL Flush Privileges
    • MySQL super Privilege
    • MySQL Character Set
    • MySQL Log File
    • MySQL Flush Log
    • Grant Privileges MySQL
    • MySQL WHILE LOOP
    • IF Statement in MySQL
    • MySQL CASE Statement
    • MySQL IF Function
    • MySQL IF EXISTS
    • MySQL UUID
    • Views in MySQL
    • MySQL Replication
    • MySQL Partition
    • Toad for MySQL
    • Navicat for MySQL
    • MySQL AES_Encrypt
    • MySQL Performance Tuning
    • MySQL Transaction
    • MySQL? sort_buffer_size
    • MySQL? Sync
    • MySQL? Query Cache
    • MySQL Collation
    • MySQL ODBC Driver
    • MySQL Partitioning
    • MySQL InnoDB
    • MySQL Float vs Decimal
    • MySQL Union vs Union All
  • Basic
    • MySQL floor
    • MySQL DESCRIBE table
    • MySQL encryption
    • Introduction to MySQL
    • Is SQL Server a Database?
    • What is MySQL
    • Is MySQL Programming Language
    • MySQL Server
    • MySQL AB
    • MySQL Community Server
    • How To Install MySQL
    • MySQL Versions
    • MySQL OpenSource
    • MySQL GUI Tools
    • MySQL Grant
    • MySQL Error 1064
    • MySQL Drop Database
    • MySQL not equal
    • MySQL SELECT INTO Variable
    • MySQL Commands
    • MySQL Operators
    • What is MySQL Schema
    • Wildcards in MySQL
    • MySQL Constraints
    • MySQL Administration
    • MySQL Data Type
    • MYSQL COMMIT
    • MySQL FORMAT
    • Timestamp to Date in MySQL
    • MySQL DATEDIFF
    • MySQL?Incremental Backup
    • MySQL JSON Data Type
    • MySQL ENUM
    • MySQL Default Port
    • Cheat Sheet MySQL
  • Queries
    • MySQL Queries
    • MySQL Query Commands
    • SELECT in MySQL
    • MySQL INSERT IGNORE
    • MySQL having
    • ORDER BY in MySQL
    • MySQL Cheat Sheet
    • MySQL ORDER BY Random
    • MySQL ORDER BY DESC
    • MySQL GROUP BY
    • MySQL GROUP BY Count
    • MySQL GROUP BY month
    • MySQL WHERE Clause
    • MySQL WITH
    • MySQL FETCH
    • MySQL DDL
    • MySQL DML
    • MySQL WHERE IN Array
    • MySQL Fetch Array
    • MySQL ISNULL
    • MySQL Index Types
    • Mysql? Export Schema
    • Amazon RDS for MySQL
    • MySQL greatest
  • Database
    • What is Data Modeling
    • What is Data Processing
    • DBMS Architecture
    • DBMS Keys
    • Careers in Database Administration
    • What is MySQL Database
    • MySQL Relational Database
    • How to Connect Database to MySQL
    • MySQL Database Repair
    • RDBMS Interview Questions
    • DBMS Interview Questions
  • Functions
    • MySQL Function
    • MySQL Aggregate Function
    • MySQL String functions
    • MySQL Date Functions
    • MySQL Window Functions
    • MySQL Math Functions
    • MySQL Boolean
    • Cursor in MySQL
    • Condition in MySQL
    • MySQL BETWEEN
    • Insert in MySQL
    • MySQL IFNULL()
    • MySQL TIMESTAMPDIFF()
    • MySQL COALESCE()
    • MySQL count()
    • MIN() in MySQL
    • MySQL Numeric
    • MySQL field()
    • MySQL FIND_IN_SET()
    • MySQL avg()
    • MySQL MAX() Function
    • MySQL BIN()
    • MySQL Concat
    • MySQL DECODE()
    • MySQL REGEXP_REPLACE()
    • MySQL Asynchronous
    • MySQL innodb_buffer_pool_size
    • MySQL key_buffer_size
    • MySQL TRUNCATE()
    • MySQL ROW_NUMBER()
    • NOT in MySQL
    • MySQL IN Operator
    • LIKE in MySQL
    • ANY in MySQL
    • MySQL NOT IN
    • MySQL CHECK Constraint
    • MySQL DISTINCT
    • MySQL ALL
    • MySQL Union
    • MySQL UNION ALL
    • MySQL EXISTS
    • MySQL ON DELETE CASCADE
    • MySQL REGEXP
    • MySQL Index
    • MySQL Add Index
    • MySQL REINDEX
    • MySQL UNIQUE INDEX
    • MySQL Clustered Index
    • MySQL? InnoDB Cluster
    • Table in MySQL
    • ALTER TABLE MySQL
    • MySQL Temporary Table
    • MySQL Clone Table
    • MySQL Repair Table
    • MySQL Lock Table
    • MySQL Optimize Table
    • TRUNCATE TABLE MySQL
    • MySQL Table Dump
    • MySQL Update Set
    • MySQL ALTER TABLE Add Column
    • MySQL RANK()
    • MySQL CTE
    • MySQL LAG()
    • MySQL GROUP_CONCAT()
    • MySQL EXTRACT()
    • MySQL REPLACE
    • MySQL AUTO_INCREMENT
    • MySQL SYSDATE()
    • MySQL NULLIF()
    • MySQL Substring
    • MySQL SUBSTRING_INDEX()
    • MySQL LOWERCASE
    • MySQL Row
    • MySQL NOW
    • MySQL CEIL
    • MySQL Alias
    • MySQL Trigger
    • MySQL SHOW Triggers
    • MySQL UPDATE Trigger
    • MySQL DELETE Trigger
    • MySQL AFTER UPDATE Trigger
    • MySQL Stored Procedure
    • ROLLUP in MySQL
    • MySQL? INSTR()
    • MySQL Subquery
    • MySQL Timestamp
    • MySQL? Hour()
    • MySQL MOD()
    • MySQL DATE_FORMAT()
    • ALTER Column in MySQL
    • MySQL Rename Column
    • MySQL Interval
    • MySQL CURDATE
    • MySQL BIT
    • MySQL Binlog
    • MySQL Average
    • MySQL TEXT
    • MySQL SHOW
    • MySQL Offset
    • MySQL Timezone
    • mysql_real_escape_string
    • MySQL Datetime
    • MySQL DATE_SUB()
    • MySQL FULLTEXT
    • MySQL DATE_ADD()
    • MySQL sum()
    • MySQL Merge
    • MySQL BigInt
    • MySQL ROUND
    • MySQL VARCHAR
    • MySQL Decimal
    • MySQL Limit
    • MySQL today()
    • MySQL WEEKDAY
    • MySQL Split
    • MySQL Create Function
    • MySQL BLOB
    • MySQL encode()
    • MySQL Primary Key
    • MySQL Foreign Key
    • Unique Key in MySQL
    • MySQL Drop Foreign Key
    • MySQL DROP TRIGGER
    • MYSQL Database
    • Delete Database MySQL
    • MySQL Root
    • MySQL Root Password
    • MySQL Client
    • MySQL Users
    • MySQL?User Permissions
    • MySQL add user
    • MySQL List User
    • MySQL Show Users
    • MySQL User Password
    • MySQL?Cardinality
    • MySQL Workbench
    • MySQL Backup
    • MySQL REVOKE
    • MySQL Dump
    • MySQL Cluster
    • MySQL Partitioning
    • MySQL Full Text Search
    • MySQL Admin Tool
    • MySQL Export Database
    • MySQL Export to CSV
  • Joins
    • Joins in MySQL
    • MySQL Outer Join
    • Left Outer Join in MySQL
    • MySQL Self Join
    • Natural Join in MySQL
    • MySQL DELETE JOIN
    • MySQL Update Join
    • MySQL Cross Join
  • Interview Questions
    • MySQL Interview Questions

Related Courses

MS SQL Certification Courses

Oracle Certification Courses

PL/SQL Certification Courses

MySQL Performance Tuning

MySQL Performance Tuning

Introduction to MySQL Performance Tuning

MySQL Performance Tuning is a MySQL technique to enhance the MySQL queries to make the speed and performance of the database better. In MySQL, the special language SQL (Structured Query Language) is used to write command or do programming in the server so that we can create, insert, update, modify, delete and fetch data records from the MySQL database. The SQL programming is implemented and found to be applied in many relational databases such as MySQL, SQL Server, Oracle, Postgres and others.

By applying the SQL query statements, a programmer can easily perform different functional server operations like CRUD events on data, creating triggers, etc. Now, therefore it is beneficial to make MySQL databases to be optimized properly as the quantity of data grows and the technology gets progressively complex. This will ensure to bring end-user understanding and will minimize the substructure costs.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

How to Perform Performance Tuning in MySQL?

  • With the growing data dimensions which have given complexity with workloads, the MySQL Performance tuning and database query enhancing is essential to maximize system presentation and resource consumption.
  • There may be a number of motives why MySQL tuning process will be a bit difficult for the developers because initially it may require broad technical proficiency to code and recognize several executional strategies. It is the task of one who can utilize the knowledge while scripting clean and comprehensive MySQL statements.
  • Besides its complication, the tuning is considered to be very time overwhelming. There are various benefits of it. Once the MySQL Tuning is done properly the database will result in sensible performance and excessive functionalities with quick data retrieval which ultimately reduces the cost and improves the data storage in the server. This performance tuning will improve the memory bandwidth, Disk seeks, reading and writing, CPU cycles and network utilizations on queries execution in the MySQL server as these elements basically are the sources from where the system performance may be hampered or slow down.

Examples of MySQL Performance Tuning

Following are few factors to be implemented for MySQL Performance Tuning and maintaining the database operations and query execution:

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (86,768 ratings)

Example #1

Procedures for query optimization in MySQL.

We have to follow the best practices to make MySQL Performance Tuning process effective for database speed and maintenance.

a. Indexing all columns applied in WHERE, ORDER BY, GROUP BY & JOIN clauses

An index not only uniquely evaluates the records from databases but also allows the server to retrieve the results quicker from the MySQL queries executed.

Suppose we have table Products and we can create an index in MySQL using the query below:

Code:

select * from products;

Output:

MySQL Performace Tuning 1

Syntax:

CREATE INDEX IndexName ON TableName(ColumnName1, ColumnName2,….);

CREATE INDEX Productinfo ON Products (Product_Name);

Output:

MySQL Performace Tuning 2

Improper indexing of queries may lead to table scans that will give locking type problems and slow performance issue.

b. Escape using functions with columns

If a column has some functions predefined on it then, the MySQL database will not make the use index associated to it.

For illustration, let us consider a query:

Code:

SELECT * FROM TableA WHERE UCASE(ColumnA) = ‘XYZ’ ;

Due to the function UCASE() the database will not apply the index on ColumnA. You need to build up a new function based index otherwise produce custom columns to optimize performance.

c. Not to use LIKE expression with wildcard(%) in the start

The predicate such as LIKE ‘%ghj’ will cause full table scan that leads to performance drawback.

For Example:

SELECT * FROM TableName WHERE ColumnA LIKE ‘%GHJ’;

d. Escape pointless fields in SELECT clause

We should specify the column names that we need to fetch from the query instead of all the columns where some might be not necessary to be fetched using SELECT * option. This may bring slow speed and execution load on the database.

e. Application of INNER JOIN rather than OUTER JOIN

We must apply outer join in MySQL only if required otherwise when used not needed may give reduced execution speed and hamper the performance of database.

f. Adding if necessary the DISTINCT and UNION options

Without any main target, try to avoid use of UNION and DISTINCT MySQL operators which will bring undesirable sorting and slow server execution. But we can use UNION ALL instead of UNION, to increase efficiency.

g. Use of ORDER BY MySQL clause for sorted list

To have an impactful result, we can use ORDER BY clause to order the rows in used columns type that make advantages for tuning performance.

h. Escape use of NULL values

We may have some column value containing NULL inputs that may harm the MySQL results during query execution of all records. For this, we can use IFNULL statement too to provide alternative result.

Example #2

Avoid use of MySQL as Queue.

Using of queues may affect the database performance by increasing workload and does not make the task complete as it creates additional load time without any reason to manage the database resources.

Example #3

Accepting the four MySQL major resources.

We need to work on the four main resources that make the database to function properly to have performance tuning. They are Memory, CPU, Network and disk.We have to be careful in selecting hardware and solving any problems with it to avoid the server performance to be affected.

Example #4

Pagination MySQL Queries.

Pagination used in applications tend to show server slow speed. This can be optimized with user interface where we can display a link to the next page instead of showing the precise number of pages and irrelevant links to separate pages.

Example #5

To improve MySQL Subqueries.

Subqueries give an intense work to the server and we must prefer to use JOIN clauses as an alternative to help in database optimization.

Example #6

Query Cache in MySQL.

Caching the contents in database like SELECT query text, while fetching the result is an important factor to maximize performance.

We can do this by:

Code:

SET GLOBALquery_cache_size = 30000;

Example #7

Using Memcached for Caching in MySQL.

Memcached helps to speed up websites containing huge dynamic databases using distributed memory caching system. Here, the database objects are sorted in Dynamic Memory to decrease the pressure on the server.

Conclusion

MySQL Performance regulation is responsible to craft effective query statements and provides a well-structured design of your database that will be simple to be maintained. Not only this, it also gives constancy to the website or software applications. The MySQL Performance Tuning process delivers some tools that can support the database professionals to swiftly recognize bottlenecks, inadequate target operations through analysis of query code plans and eradicate any predicting games.

Recommended Articles

This is a guide to MySQL Performance Tuning. Here we discuss the introduction, how to perform performance tuning in MySQL? and examples respectively. You may also have a look at the following articles to learn more –

  1. MySQL Repair Table
  2. MySQL DELETE JOIN
  3. MySQL Transaction
Popular Course in this category
MySQL Training Program (12 Courses, 10 Projects)
  12 Online Courses |  10 Hands-on Projects |  92+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

MS SQL Training (16 Courses, 11+ Projects)4.9
Oracle Training (14 Courses, 8+ Projects)4.8
PL SQL Training (4 Courses, 2+ Projects)4.7
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more