General |  Social Media |  Miscellaneous
Login | Register
srcraft blog logo
  • Business
  • News
  • Shopping
  • Travel
  • Disease
  • Pets
  • Life
  • Health
  • Technology
  • Category
  • Contact Us
Latest Blog : 
☛ Who can be called a true monk ? ☛ God arranges everything ☛ Faith in god ☛ What is a Rotary Encoder? How does it work? ☛ Things to Know About PLC and SCADA ☛ According to Ramayana, why do women wear jewelry? ☛ After registering an FIR, can I not apply for a government job ☛ Daughter: A angel of his father ☛ How VOIP Phone System is Useful For your Business? ☛ test 
Home > Innovation & Technology > Mysql

How to reduce MySQL query execution time


How to reduce MySQL query execution time

If you are using join in MYSQL for adding multiple tables and you didn't configure server engine and storage architecture, then your query may take a minute in execution. The default time of MYSQL query execution is 0.5 second. The execution time of MySQL query depends on various factors like type of server engine, storage architecture, database and table structure, load and contention, and network latency.

Here we are going to see some basic things that increase MySQL query execution time.

  1. Avoid functions in where clauses
  2. Avoid arithmetic in where clauses
  3. Avoid "Outer JOIN"
  4. Avoid " GROUP BY, ORDER BY, LIKE, DISTINCT " operator. They are consuming more time.
  5. Do not use sub-queries

 

For reducing MySQL query execution time see below steps

  1. Creating better indexes
  2. Use "explain"
  3. Join all table with each other by unique and same column name
  4. Use short query with supported column
  5. Use best hardware configuration with the hosting server
  6. Increase cache and RAM in your hardware.

 

How to check query performance in mysql

<?php

include('config.php');

//Record start time before query is executed

$start_time = microtime(true);

 

//Run your MYSQL query

mysqli_query($db, "SELECT * FROM table_name ");

 

//After query has finished running, Record the end time

$end _time= microtime(true);

 

//Calculate the difference of start time and end time of mysql query execution in microseconds

$diff = $end_time - $start_time;

 

//Format the time so that it only shows 10 decimal places

$ActualqueryTime = number_format($diff, 10);

 

//Print out the seconds it took for the query to execute

echo "MYSQL query took $ ActualqueryTime seconds.";

?>

Written By: Charles Miller Published in Mysql


Search

Publish your passions on srcraftblog.com

Latest Post

☛ Who can be called a true monk ?

☛ God arranges everything

☛ Faith in god

☛ What is a Rotary Encoder? How does it work?

☛ Things to Know About PLC and SCADA

☛ According to Ramayana, why do women wear jewelry?

☛ After registering an FIR, can I not apply for a government job

☛ Daughter: A angel of his father

☛ 'Gurukul' literally means 'family of Guru' or 'clan of Guru'

☛ When does mother's honor get less


We are accepting well-written informative Guest Posts on srcraftblog.com

Innovation & Technology

Artificial Intelligent blogs
Cryptocurrency blogs
Digital India blogs
Data science blogs
Neuroscience blogs
Programming blogs

Physical science

Physics blogs
Chemistry blogs
Earth science blogs
Geology blogs
Oceanography blogs
Meteorology blogs

Industry

Business blogs
Economy blogs
Freelancing blogs
Leadership blogs
Productivity blogs
Work blogs

Society

Basic income blogs
Education blogs
Environment blogs
Media blogs
Philosophy blogs
Women blogs
About us |  Write for us |  Terms and conditions |  Contact us

© 2021 SRCRAFT INIDA