Let’s take an example table called “sample” with only two rows – “number” and “employee”. If you run a simple SQL query such as:

SELECT * FROM sample WHERE number = 4;
MySQL will check all records and will return only the one that has its number value set to 4.

But if you have several thousand entries for example, this will be a slow query. In this case we have a unique field – “number”. Therefore, we can create an index for it. Indexing will create an internal register that is saved in by the MySQL service. It can be done with the following query:

ALTER TABLE sample ADD INDEX (number);

Once this index is set, next time you want to get the information for employee number 4, the service will go directly to it using the index and will return the information much faster.
This is just a very basic example. For bigger databases, the difference in the loading time can be significant. Indexing your database can drastically decrease the loading time of your web applications.

There is another query that you can use to increase the loading speed of your database:

OPTIMIZE TABLE sample;

You can also check our tutorial below which will help you to Repair/Optimize your database using phpMyAdmin:

How can you see all indexes defined for a table?

Indexes are defined for the table by:

SHOW INDEX FROM ;


function woocommerce_yoast_fix_style() {
    echo '
    .widefat * {
    word-wrap: normal !important;
    }
     ';
}
add_action('admin_head', 'woocommerce_yoast_fix_style');

Here are the tables which required optimization in Magento:

log_customer
log_visitor
log_visitor_info
log_url
log_url_info
log_quote
report_viewed_product_index
report_compared_product_index
report_event
catalog_compare_item
Execute below MySQL queries for the log cleaning of Magento database:

TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_viewed_product_index;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE index_event;
TRUNCATE catalog_compare_item;