SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  descr1.product as product, 
  companies.company as company_name, 
  products.product_type, 
  products.parent_product_id, 
  cscart_product_review_prepared_data.average_rating average_rating, 
  cscart_product_review_prepared_data.reviews_count product_reviews_count 
FROM 
  cscart_products as products 
  LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'vi' 
  LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id 
  AND prices.lower_limit = 1 
  LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id 
  INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id 
  LEFT JOIN cscart_product_review_prepared_data ON cscart_product_review_prepared_data.product_id = products.product_id 
  AND cscart_product_review_prepared_data.storefront_id = 0 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id 
WHERE 
  1 
  AND cscart_categories.category_id IN (166) 
  AND companies.status IN ('A') 
  AND (
    products.amount > 0 
    OR products.tracking = 'D'
  ) 
  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 
  popularity.total desc, 
  products.product_id ASC 
LIMIT 
  128, 32

Query time 0.40141

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "sort_key": "popularity.total desc, products.product_id",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_categories",
              "access_type": "const",
              "possible_keys": ["PRIMARY", "p_category_id"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["category_id"],
              "ref": ["const"],
              "rows": 1,
              "filtered": 100,
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "pt"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["category_id"],
              "ref": ["const"],
              "rows": 1194,
              "filtered": 100,
              "attached_condition": "products_categories.category_id <=> 166",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "status", "idx_parent_product_id"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["dev_db.products_categories.product_id"],
              "rows": 1,
              "filtered": 18.48341942,
              "attached_condition": "products.parent_product_id = 0 and (products.amount > 0 or products.tracking = 'D') and (products.usergroup_ids = '' or find_in_set(0,products.usergroup_ids) or find_in_set(1,products.usergroup_ids)) and products.`status` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "companies",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "4",
              "used_key_parts": ["company_id"],
              "ref": ["dev_db.products.company_id"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "companies.`status` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "descr1",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "product_id"],
              "key": "PRIMARY",
              "key_length": "11",
              "used_key_parts": ["product_id", "lang_code"],
              "ref": ["dev_db.products_categories.product_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(descr1.lang_code = 'vi')"
            }
          },
          {
            "table": {
              "table_name": "cscart_product_review_prepared_data",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "7",
              "used_key_parts": ["product_id", "storefront_id"],
              "ref": ["dev_db.products_categories.product_id", "const"],
              "rows": 1,
              "filtered": 100
            }
          },
          {
            "table": {
              "table_name": "popularity",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "total"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["dev_db.products_categories.product_id"],
              "rows": 1,
              "filtered": 100
            }
          },
          {
            "table": {
              "table_name": "prices",
              "access_type": "ref",
              "possible_keys": [
                "usergroup",
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "key": "product_id",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["dev_db.products_categories.product_id"],
              "rows": 1,
              "filtered": 99.9960556,
              "attached_condition": "prices.lower_limit = 1 and prices.usergroup_id in (0,0,1)"
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name product_type parent_product_id average_rating product_reviews_count
823 Rèm Trang Trí Macrame Nhiều Màu, Phối Màu Tinh Tế, Kỹ Thuật Thắt Dây Macrame Điêu Luyện, Thiết Kế Mới Lạ Artspace P 0
36572 Hai Bông Cúc, Tranh In Trang Trí Khổ A3 / A4 Kèm Khung Hình Miễn Phí, Vẻ Đẹp Của Thiên Nhiên, Điểm Nhấn Tinh Tế Cho Không Gian Sống Nhu Pham Art P 0 0
32367 Bình Hoa Gốm Sứ Thanh Mai, Gốm Sứ Việt Nam, Vật Dụng Trang Trí, Trang Trí Nhà Cửa, Gợi Ý Quà Tặng, Quà Tân Gia, Quà Sinh Nhật, Quà Đám Cưới Lina Pottery by Minh Tien Ceramic P 0 5.00 3
29811 Khăn Ăn Linen Tua Rua, Chất Liệu Vải Linen Mềm Nhẹ, Dễ Dàng Vệ Sinh, Không Bị Phai Màu Sau Khi Giặc, Trang Trí Bàn Ăn Soft&another Home P 0 5.00 1
33262 Garden No.1, Tranh In Trang Trí Khổ A3 & A4 Kèm Khung Hình Miễn Phí Nhu Pham Art P 0 5.00 1
651 Cú Treo Tường Macrame, Thiết Kế Đáng Yêu, Trang Trí Nhà Cửa, An Toàn Cho Trẻ, Sản Phẩm Thủ Công, Sản Xuất Bền Vững Thừng Gỗ Decor P 0
37322 Giỏ Cotton Trắng Viền Xanh Móc Thủ Công, Phối Màu Độc Đáo, Chất Liệu Dày Dặn, Quà Tặng Cho Người Yêu Đồ Handmade I LOVE HANDMADE P 0 0
47610 Tranh Hoa Giấy Handmade Trang Trí - The Pink Rose MAYPAPERFLOWER Khung Gỗ Size 20x25cm, Tranh Thủ Công, Quà Tặng Cá Nhân Hóa Maypaperflower P 0 5.00 17
656 Dây Treo Chậu Cây Macrame, Dễ Dàng Vệ Sinh, Có Thể Giặt Máy, Độ Bền Cao, Phụ Kiện Trang Trí Không Gian Thêm Xanh Thừng Gỗ Decor P 0
41007 Cá Chép Bạc, Tranh Bạc Đậu, Sản Phẩm Thủ Công, Phương Pháp Đậu Bạc Truyền Thống, Tranh Trang Trí, Quà Tặng Đẳng Cấp Silver Soul Studio- Handmade in Vietnam P 0 5.00 1
41010 Chim Lạc, Tranh Bạc Đậu, Kỹ Thuật Cầu Kì, Đường Nét Tỉ Mỉ, Tác Phẩm Nghệ Thuật, Tranh Trang Trí, Chất Liệu Cao Cấp Silver Soul Studio- Handmade in Vietnam P 0
31864 Quạt Giấy Dó Trái Thông, Hình Vẽ Tay Đáng Yêu, Chất Liệu Thân Thiện Môi Trường, Giấy Dó Truyền Thống, Sản Phẩm Thủ Công Việt Hana Mascot P 0
648 Bọc Gối Tựa Lưng Macrame, Phong Cách Bohemian, Sợi Cotton Mềm Mịn, Dễ Vệ Sinh, Thấm Hút Mồ Hôi Tốt, Trang Trí Nhà Cửa Thừng Gỗ Decor P 0 5.00 1
33161 Cây Thông Macrame Giáng Sinh, Phụ Kiện Trang Trí Nhỏ Xinh, Chủ Đề Noel, Đồ Trang Trí Thủ Công Cho Không Gian Sống MIDUME P 0 0
47605 Tranh Hoa Giấy Handmade Trang Trí - Hoa Billy Ball MAYPAPERFLOWER Khung Tranh Gỗ Size 15 x 20cm Maypaperflower P 0
27938 Lót Ly Len Tua Rua, Thiết Kế Độc Đáo, Phong Cách Mộc Mạc, Tông Màu Nhã Nhặn, Thấm Hút Tốt, Hạn Chế Xù Lông, Sản Phẩm Handmade The Goods P 0 5.00 1
650 rèm dây treo tường trang trí 3 tầng macrame xanh nhạt, màu xanh tươi mát, thiết kế cầu kì, phụ kiện nội thất, sản phẩm handmade Thừng Gỗ Decor P 0
31885 Gùi Tre Trang Trí, Chất Liệu Tre Nứa, Giá Trị Về Mặt Văn Hoá, Đậm Chất Núi Rừng, Trang Trí Nhà Cửa, Quà Lưu Niệm Hana Mascot P 0
47606 Tranh Hoa Giấy Handmade Trang Trí - Khẽ Chạm MAYPAPERFLOWER Khung Gỗ Size 30 x 40cm Maypaperflower P 0
46188 CHAOS, Tranh Nghệ Thuật Trừu Tượng Vẽ Tay, Màu Sắc Tinh Tế, Thể Hiện Sự Phức Tạp Của Tình Yêu, Tác Phẩm Nghệ Thuật Trừu Tượng Ý Nghĩa Him Him Art P 0
652 Rèm Trắng Nhỏ Macrame, Màu Trắng Thuần Khiết, Độ Rũ Nhẹ Nhàng, Phù Hợp Với Nhiều Không Gian, Trang Trí Nội Thất Thừng Gỗ Decor P 0
37825 Tượng Sứ Mèo Ngồi, Mô Phỏng Dáng Mèo Thật, Màu Sắc Vẽ Tay, Tượng Sứ Phủ Men Bóng Loáng, Trang Trí Kệ Hoặc Bàn Học Và Bàn Làm Việc Art by Hang P 0 5.00 1
32368 Bình Hoa Gốm Sứ Thu Hương, Bình Hoa Thủ Công, Bình Hoa Trang Trí, Trang Trí Nội Thất, Gốm Sứ Việt, Quà Tặng Tân Gia, Quà Sinh Nhật, Quà Đám Cưới Lina Pottery by Minh Tien Ceramic P 0 5.00 3
47276 Bộ Trồng Cây Kiss The Ground, Cây Ngò Rí, Gồm Chậu Xơ Dừa Và Hạt Giống, Thân Thiện Với Môi Trường, Món Quà Cho Những Ai Thích Làm Vườn KISS Notebook & Gift P 0
37321 Giỏ Cotton Màu Vàng Móc Thủ Công, Màu Sắc Rực Rỡ Bắt Mắt, Chất Liệu Sợi Cotton Bền Chắc, Đựng Đồ Dùng, Trang Trí Phòng I LOVE HANDMADE P 0 0
2583 Cú Thông Minh Treo Tường Trang Trí Macrame, Kỹ Thuật Đan Tinh Xảo, Đồ Trang Trí Phong Thuỷ, Có Thể Giặt Máy, Sản Phẩm Handmade Thừng Gỗ Decor P 0
29815 Khăn Trải Trang Trí Bàn Ăn Tua Rua, Khăn Trang Trí Dạng Dài, Chi Tiết Tua Rua Lạ Mắt, Đa Dạng Hoạ Tiết, Trang Trí Bàn Ăn Soft&another Home P 0 0
6472 Túi Linen Tá Lả, Có 5 Ngăn Túi, Thiết Kế Thông Minh và Tiện Lợi, Các Chi Tiết Thêu Tay Tỉ Mỉ, Đồ Trang Trí Thủ Công Tạp Hóa Ú P 0 5.00 1
35651 Mành Treo Mini Ông Già Noel, Nút Thắt Cầu Kì, Hình Ảnh Ông Già Noel Đáng Yêu, Món Đồ Trang Trí Xinh Xắn Thừng Gỗ Decor P 0 5.00 1
38104 Xếp Hình Gỗ Xoắn Ốc, Đồ Chơi Rèn Luyện Trí Tuệ, Chất Liệu Gỗ Tái Chế, Gỗ Tự Nhiên Không Sơn Phủ, Món Quà Bổ Ích VietArt P 0
27952 Chậu Sen Đá Gốm Sứ Có Chân, Chất Liệu Gốm Sứ Bát Tràng, Hoạ Tiết Vẽ Tay Tỉ Mỉ, Trang Trí Bàn Học Xinh Xắn The Goods P 0 5.00 6
41008 Chim Đại Ưng Đậu Cành Cây, Tranh Bạc Đậu, Kỹ Thuật Tinh Xảo, Đường Nét Tinh Tế, Tranh Trang Trí, Sản Phẩm Thủ Công Silver Soul Studio- Handmade in Vietnam P 0