SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  descr1.product as product, 
  companies.company as company_name, 
  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') 
WHERE 
  1 
  AND q_categories.category_id IN (3, 4, 5, 39) 
  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 products.parent_product_id = 0 
GROUP BY 
  products.product_id 
ORDER BY 
  products.timestamp desc, 
  products.product_id ASC 
LIMIT 
  1170, 30

Query time 0.07331

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "97.08"
    },
    "ordering_operation": {
      "using_filesort": true,
      "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": "q_categories",
              "access_type": "range",
              "possible_keys": [
                "PRIMARY",
                "c_status",
                "p_category_id"
              ],
              "key": "p_category_id",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "rows_examined_per_scan": 4,
              "rows_produced_per_join": 0,
              "filtered": "20.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "5.45",
                "eval_cost": "0.16",
                "prefix_cost": "5.61",
                "data_read_per_join": "2K"
              },
              "used_columns": [
                "category_id",
                "usergroup_ids",
                "status"
              ],
              "attached_condition": "((`portal`.`q_categories`.`category_id` in (3,4,5,39)) and ((`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')))"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "pt"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "portal.q_categories.category_id"
              ],
              "rows_examined_per_scan": 156,
              "rows_produced_per_join": 124,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "3.91",
                "eval_cost": "24.96",
                "prefix_cost": "34.48",
                "data_read_per_join": "1K"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "status",
                "idx_parent_product_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "portal.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 110,
              "filtered": "88.70",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "22.14",
                "prefix_cost": "59.44",
                "data_read_per_join": "652K"
              },
              "used_columns": [
                "product_id",
                "product_type",
                "status",
                "company_id",
                "amount",
                "timestamp",
                "usergroup_ids",
                "tracking",
                "parent_product_id"
              ],
              "attached_condition": "((`portal`.`products`.`parent_product_id` = 0) and (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": 11,
              "filtered": "10.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "2.21",
                "prefix_cost": "81.58",
                "data_read_per_join": "61K"
              },
              "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_categories.product_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 11,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "2.21",
                "prefix_cost": "83.79",
                "data_read_per_join": "42K"
              },
              "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.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 11,
              "filtered": "99.95",
              "using_index": true,
              "cost_info": {
                "read_cost": "11.07",
                "eval_cost": "2.21",
                "prefix_cost": "97.08",
                "data_read_per_join": "265"
              },
              "used_columns": [
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "attached_condition": "((`portal`.`prices`.`lower_limit` = 1) and (`portal`.`prices`.`usergroup_id` in (0,0,1)))"
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name product_type parent_product_id
37523 Antonio Banderas Her Secret Temptation EDT 80ml+150ml Deodorant Set Smell Attractive Perfumes P 0
37524 Antonio Banderas King Of SeductionMen EDT 100ml+75ml ABS Set Smell Attractive Perfumes P 0
37525 Antonio Banderas Queen Of Seduction 80ml+150ml Deodorent Set Smell Attractive Perfumes P 0
37526 Aramis Miniature Men Aramis Eau De Toilette 7ml Aftershave 7ml Black Eau De Toilette 7ml Voyager Eau De Toilette 7ml Smell Attractive Perfumes P 0
37527 Atelier Cologne Vetiver Fatal Absolue EDP 100ml+30ml+Leather Case Travel Set Smell Attractive Perfumes P 0
37528 Azzaro Pour Homme EDT 100ml+150ml Deodrant Travel Set Smell Attractive Perfumes P 0
37529 Azzaro Wanted Men EDT 100ml+150ml Deodorant Travel Set Smell Attractive Perfumes P 0
37530 Bentley Momentum EDT 100ml+200ml Shower Gel Set Smell Attractive Perfumes P 0
37531 Beyonce Heat EDP 15ml+ Rise EDP 30ml+ Heat Rush EDT 15ml Set Smell Attractive Perfumes P 0
37532 Boucheron Iris De Syracuse EDP 125ml+Santal De Kandy EDP 125ml+Ambre D'Alexandrie EDP 125ml Set Smell Attractive Perfumes P 0
37533 Britney Spears Fantasy Women EDP 100ml+100ml Body Lotion Set Smell Attractive Perfumes P 0
37534 Britney Spears Fantasy EDP 30ml+Curious EDP 30ml+Fantasy Stage Edition EDP 30ml Set Smell Attractive Perfumes P 0
37535 Burberry Burberry Her EDP 50ml+6ml Liquid LIP Velvet Fawn Set Smell Attractive Perfumes P 0
37536 Burberry Mr Burberry EDT 2X30ml Travel Set Smell Attractive Perfumes P 0
37537 Burberry Mr Burberry Indigo EDT 5ml+ Mr Burberry EDP 5ml+ Mr Burberry EDT 2 X 5ml Mini Set Smell Attractive Perfumes P 0
37538 Burberry My Burberry Women EDP 90ml+6ml Kisses Gloss Sugar Pink+3.5ml Mascara Set Smell Attractive Perfumes P 0
37539 Burberry My Burberry Women EDT 5ml+EDP 5ml+My Burberry Black EDP 5ml+Blush EDP 5ml Mini Set Smell Attractive Perfumes P 0
37540 Burberry My Burberry Women 5ml+My Burberry EDP 2 X 5ml+My Burberry Black 5ml Mini Set Smell Attractive Perfumes P 0
37541 Burberry My Burberry BlackWomen EDP 50ml+75ml Bl Set Smell Attractive Perfumes P 0
37542 My Burberry Black EDP+ 75ml Travel Women Smell Attractive Perfumes P 0
37543 Burberry My Burberry Blush Women EDP 90ml+3.3G Lipstick Set Smell Attractive Perfumes P 0
37544 Burberry My Limited Edition EDP 90ml+30ml Body Oil+10G Gold Glow Powder Set Smell Attractive Perfumes P 0
37545 Bvlgari Aqva Men's Deodorant Stick 75ml Smell Attractive Perfumes P 0
37546 Bvlgari Aqva Divina Women EDT 65ml+100ml Bl+150G Soap+100ml Sg Set Smell Attractive Perfumes P 0
37547 Bvlgari Aqva Divina Women EDT 65ml+40ml Bl+40ml Sg+50G Soap+Pouch Set Smell Attractive Perfumes P 0
37548 Bvlgari Aqva Pour Homme EDT 3X15ml Refillable Travel Set Smell Attractive Perfumes P 0
37549 Bvlgari Blv Men EDT 100ml+75ml Asb+75ml Sg+Pouch Set Smell Attractive Perfumes P 0
37550 Bvlgari Goldea EDP 50ml+25ml+Mirror Set Smell Attractive Perfumes P 0
37551 Goldea The Roman Night by Bvlgari Gift Set for Women - Eau de Parfum Smell Attractive Perfumes P 0
37552 Bvlgari Goldea The Roman Night Set EDP Smell Attractive Perfumes P 0