[Solved] Query optimization | Magento | MariaDB

How to optimize this SQL query?

In case you have your own slow SQL query, you can optimize it automatically here.

For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:

  1. Description of the steps you can take to speed up the query.
  2. The optimal indexes for this query, which you can copy and create in your database.
  3. An automatically re-written query you can copy and execute in your database.
The optimization process and recommendations:
  1. Mixed Order By Directions Prevents Index Use (modified query below): The database will not use a sorting index (if exists) in cases where the query mixes ASC (the default if not specified) and DESC order. To avoid filesort, you may consider using the same order type for all columns. Another option that will allow you to switch one direction to another is to create a new reversed "sort" column (max_sort - sort) and index it instead.
The optimized query:
        `m2epro_listing_product_instruction` AS `lpsi` 
        `m2epro_processing_lock` AS `pl` 
            ON pl.object_id = lpsi.listing_product_id 
            AND model_name = 'M2ePro/Listing_Product' 
            lpsi.component = 'ebay'
        AND (
            pl.id IS NULL
        MAX(lpsi.priority) DESC,
        MIN(lpsi.create_date) ASC LIMIT 10

Related Articles

* original question posted on StackOverflow here.