SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  descr1.product as product, 
  companies.company as company_name, 
  variation_group_products.group_id AS variation_group_id, 
  products.product_type, 
  products.parent_product_id 
FROM 
  q_products as products 
  LEFT JOIN q_product_options_inventory as inventory ON inventory.product_id = products.product_id 
  LEFT JOIN q_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'en' 
  LEFT JOIN q_product_prices as prices ON prices.product_id = products.product_id 
  AND prices.lower_limit = 1 
  LEFT JOIN q_companies AS companies ON companies.company_id = products.company_id 
  INNER JOIN q_products_categories as products_categories ON products_categories.product_id = products.product_id 
  INNER JOIN q_categories ON q_categories.category_id = products_categories.category_id 
  AND (
    q_categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, q_categories.usergroup_ids) 
    OR FIND_IN_SET(1, q_categories.usergroup_ids)
  ) 
  AND q_categories.status IN ('A', 'H') 
  INNER JOIN q_product_variation_group_products AS variation_group_products ON variation_group_products.product_id = products.product_id 
WHERE 
  1 
  AND companies.status = 'A' 
  AND (
    CASE products.tracking WHEN 'O' THEN inventory.amount > 0 WHEN 'B' THEN products.amount > 0 ELSE 1 END
  ) 
  AND (
    products.usergroup_ids = '' 
    OR FIND_IN_SET(0, products.usergroup_ids) 
    OR FIND_IN_SET(1, products.usergroup_ids)
  ) 
  AND products.status IN ('A') 
  AND prices.usergroup_id IN (0, 0, 1) 
  AND variation_group_products.group_id IN (
    36, 34, 37, 31, 39, 38, 30, 32, 33, 46, 47, 
    52, 54, 56, 55, 57
  ) 
GROUP BY 
  products.product_id 
ORDER BY 
  NULL asc

Query time 0.00304

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "171.57"
    },
    "ordering_operation": {
      "using_filesort": false,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "inventory",
              "access_type": "system",
              "possible_keys": [
                "pc"
              ],
              "rows_examined_per_scan": 0,
              "rows_produced_per_join": 1,
              "filtered": "0.00",
              "const_row_not_found": true,
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.20",
                "prefix_cost": "0.00",
                "data_read_per_join": "976"
              },
              "used_columns": [
                "product_id",
                "amount"
              ]
            }
          },
          {
            "table": {
              "table_name": "variation_group_products",
              "access_type": "range",
              "possible_keys": [
                "PRIMARY",
                "idx_group_id"
              ],
              "key": "idx_group_id",
              "used_key_parts": [
                "group_id"
              ],
              "key_length": "4",
              "rows_examined_per_scan": 76,
              "rows_produced_per_join": 76,
              "filtered": "100.00",
              "index_condition": "(`portal`.`variation_group_products`.`group_id` in (36,34,37,31,39,38,30,32,33,46,47,52,54,56,55,57))",
              "cost_info": {
                "read_cost": "107.21",
                "eval_cost": "15.20",
                "prefix_cost": "122.41",
                "data_read_per_join": "1K"
              },
              "used_columns": [
                "product_id",
                "group_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "status"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "portal.variation_group_products.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 70,
              "filtered": "93.11",
              "index_condition": "(`portal`.`variation_group_products`.`product_id` = `portal`.`products`.`product_id`)",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "14.15",
                "prefix_cost": "137.61",
                "data_read_per_join": "417K"
              },
              "used_columns": [
                "product_id",
                "product_type",
                "status",
                "company_id",
                "amount",
                "usergroup_ids",
                "tracking",
                "parent_product_id"
              ],
              "attached_condition": "((case `portal`.`products`.`tracking` when 'O' then <cache>((NULL > 0)) when 'B' then (`portal`.`products`.`amount` > 0) else 1 end) and ((`portal`.`products`.`usergroup_ids` = '') or find_in_set(0,`portal`.`products`.`usergroup_ids`) or find_in_set(1,`portal`.`products`.`usergroup_ids`)) and (`portal`.`products`.`status` = 'A'))"
            }
          },
          {
            "table": {
              "table_name": "companies",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "company_id"
              ],
              "key_length": "4",
              "ref": [
                "portal.products.company_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "10.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "1.42",
                "prefix_cost": "151.76",
                "data_read_per_join": "39K"
              },
              "used_columns": [
                "company_id",
                "status",
                "company"
              ],
              "attached_condition": "(`portal`.`companies`.`status` = 'A')"
            }
          },
          {
            "table": {
              "table_name": "descr1",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "product_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id",
                "lang_code"
              ],
              "key_length": "9",
              "ref": [
                "portal.products.product_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "1.42",
                "prefix_cost": "153.18",
                "data_read_per_join": "26K"
              },
              "used_columns": [
                "product_id",
                "lang_code",
                "product"
              ]
            }
          },
          {
            "table": {
              "table_name": "prices",
              "access_type": "ref",
              "possible_keys": [
                "usergroup",
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "key": "usergroup",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "portal.variation_group_products.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "99.95",
              "using_index": true,
              "cost_info": {
                "read_cost": "7.08",
                "eval_cost": "1.41",
                "prefix_cost": "161.67",
                "data_read_per_join": "169"
              },
              "used_columns": [
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "attached_condition": "((`portal`.`prices`.`lower_limit` = 1) and (`portal`.`prices`.`product_id` = `portal`.`products`.`product_id`) and (`portal`.`prices`.`usergroup_id` in (0,0,1)))"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "pt"
              ],
              "key": "pt",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "portal.variation_group_products.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "100.00",
              "index_condition": "(`portal`.`products_categories`.`product_id` = `portal`.`products`.`product_id`)",
              "cost_info": {
                "read_cost": "7.07",
                "eval_cost": "1.41",
                "prefix_cost": "170.16",
                "data_read_per_join": "113"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "q_categories",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "c_status",
                "p_category_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "portal.products_categories.category_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "20.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.28",
                "prefix_cost": "171.57",
                "data_read_per_join": "3K"
              },
              "used_columns": [
                "category_id",
                "usergroup_ids",
                "status"
              ],
              "attached_condition": "(((`portal`.`q_categories`.`usergroup_ids` = '') or find_in_set(0,`portal`.`q_categories`.`usergroup_ids`) or find_in_set(1,`portal`.`q_categories`.`usergroup_ids`)) and (`portal`.`q_categories`.`status` in ('A','H')))"
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name variation_group_id product_type parent_product_id
2942 Y&D Evening & Formal Beach A Line Dress For Women J D F General Trading LLC 30 P 0
3088 Y&D Evening & Formal Beach A Line Dress For Women J D F General Trading LLC 30 V 2942
3090 Y&D Evening & Formal Beach A Line Dress For Women J D F General Trading LLC 30 V 2942
3091 Y&D Evening & Formal Beach A Line Dress For Women J D F General Trading LLC 30 V 2942
3043 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 P 0
3092 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3093 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3094 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3095 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3096 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3097 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3098 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3099 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3100 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3101 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3102 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3104 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3105 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3106 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3107 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3108 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3109 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3110 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
3111 Y&D Women's O Neck Elegent Flower Pattern A Line Maxi Long Dress J D F General Trading LLC 31 V 3043
2946 Y&D Women's A Line Floral Pattern Sleeve Maxi Dress J D F General Trading LLC 32 P 0
3130 Y&D Women's A Line Floral Pattern Sleeve Maxi Dress J D F General Trading LLC 32 V 2946
3131 Y&D Women's A Line Floral Pattern Sleeve Maxi Dress J D F General Trading LLC 32 V 2946
3132 Y&D Women's A Line Floral Pattern Sleeve Maxi Dress J D F General Trading LLC 32 V 2946
3133 Y&D Women's A Line Floral Pattern Sleeve Maxi Dress J D F General Trading LLC 32 V 2946
2951 Y&D Women's A Line Floral Pattern Round Neck Patchwork Bow Decor Flare Sleeve Maxi Long Dress Multi Color J D F General Trading LLC 33 P 0
3135 Y&D Women's A Line Floral Pattern Round Neck Patchwork Bow Decor Flare Sleeve Maxi Long Dress Multi Color J D F General Trading LLC 33 V 2951
3136 Y&D Women's A Line Floral Pattern Round Neck Patchwork Bow Decor Flare Sleeve Maxi Long Dress Multi Color J D F General Trading LLC 33 V 2951
3137 Y&D Women's A Line Floral Pattern Round Neck Patchwork Bow Decor Flare Sleeve Maxi Long Dress Multi Color J D F General Trading LLC 33 V 2951
3033 Y&D Women's Casual Aline Round Neck Short Sleeve Floral Comfy Flower Printed Maxi Long Dress J D F General Trading LLC 34 P 0
3139 Y&D Women's Casual Aline Round Neck Short Sleeve Floral Comfy Flower Printed Maxi Long Dress J D F General Trading LLC 34 V 3033
3140 Y&D Women's Casual Aline Round Neck Short Sleeve Floral Comfy Flower Printed Maxi Long Dress J D F General Trading LLC 34 V 3033
3141 Y&D Women's Casual Aline Round Neck Short Sleeve Floral Comfy Flower Printed Maxi Long Dress J D F General Trading LLC 34 V 3033
3142 Y&D Women's Casual Aline Round Neck Short Sleeve Floral Comfy Flower Printed Maxi Long Dress J D F General Trading LLC 34 V 3033
3028 Y&D Evening & Formal Straight Dress For Women J D F General Trading LLC 36 P 0
3162 Y&D Evening & Formal Straight Dress For Women J D F General Trading LLC 36 V 3028
3163 Y&D Evening & Formal Straight Dress For Women J D F General Trading LLC 36 V 3028
3164 Y&D Evening & Formal Straight Dress For Women J D F General Trading LLC 36 V 3028
3165 Y&D Evening & Formal Straight Dress For Women J D F General Trading LLC 36 V 3028
3038 Y&D Women's Aline Round Neck Short Sleeve Floral Comfy Fashion Maxi Long Dress - Green J D F General Trading LLC 37 P 0
3167 Y&D Women's Aline Round Neck Short Sleeve Floral Comfy Fashion Maxi Long Dress - Green J D F General Trading LLC 37 V 3038
3168 Y&D Women's Aline Round Neck Short Sleeve Floral Comfy Fashion Maxi Long Dress - Green J D F General Trading LLC 37 V 3038
3169 Y&D Women's Aline Round Neck Short Sleeve Floral Comfy Fashion Maxi Long Dress - Green J D F General Trading LLC 37 V 3038
3170 Y&D Women's Aline Round Neck Short Sleeve Floral Comfy Fashion Maxi Long Dress - Green J D F General Trading LLC 37 V 3038
3071 Y&D Women's Dress Sleeveless V Neck Solid White Color Slip Dress J D F General Trading LLC 38 P 0
3172 Y&D Women's Dress Sleeveless V Neck Solid White Color Slip Dress J D F General Trading LLC 38 V 3071
3173 Y&D Women's Dress Sleeveless V Neck Solid White Color Slip Dress J D F General Trading LLC 38 V 3071
3067 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 P 0
3175 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
3176 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
3177 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
3178 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
3179 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
3180 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
3181 Y&D Evening & Formal A Line Dress For Women J D F General Trading LLC 39 V 3067
2955 Y&D Maxi Shirt Neck Print Pattern Straight Dress For Women J D F General Trading LLC 46 P 0
4667 Y&D Maxi Shirt Neck Print Pattern Straight Dress For Women J D F General Trading LLC 46 V 2955
4668 Y&D Maxi Shirt Neck Print Pattern Straight Dress For Women J D F General Trading LLC 46 V 2955
4669 Y&D Maxi Shirt Neck Print Pattern Straight Dress For Women J D F General Trading LLC 46 V 2955
2959 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 47 P 0
5806 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 47 V 2959
5807 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 47 V 2959
5808 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 47 V 2959
2963 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 P 0
5986 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5987 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5988 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5989 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5990 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5991 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5992 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
5993 Y&D Maxi Shirt Neck Floral Pattern Straight Dress For Women J D F General Trading LLC 52 V 2963
2972 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 54 P 0
5999 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 54 V 2972
6000 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 54 V 2972
6001 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 54 V 2972
2980 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 55 P 0
6003 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 55 V 2980
6004 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 55 V 2980
6005 Y&D Maxi Round Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 55 V 2980
2976 Y&D Maxi Shirt Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 56 P 0
6007 Y&D Maxi Shirt Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 56 V 2976
6008 Y&D Maxi Shirt Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 56 V 2976
6009 Y&D Maxi Shirt Neck Print Pattern Full Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 56 V 2976
2984 Y&D Maxi Shirt Neck Animal Print Pattern Three Quarter Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 57 P 0
6011 Y&D Maxi Shirt Neck Animal Print Pattern Three Quarter Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 57 V 2984
6012 Y&D Maxi Shirt Neck Animal Print Pattern Three Quarter Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 57 V 2984
6013 Y&D Maxi Shirt Neck Animal Print Pattern Three Quarter Sleeve Straight Dress For Women Multi Color J D F General Trading LLC 57 V 2984