SELECT 
  pf.feature_id, 
  pf.feature_style, 
  pf.position, 
  pf.purpose, 
  pf.display_on_catalog, 
  pfd.description, 
  pfd.internal_name, 
  pfd.prefix, 
  pfd.suffix, 
  (
    CASE WHEN pf.purpose = 'group_catalog_item' THEN 0 ELSE 1 END
  ) AS purpose_position 
FROM 
  cscart_product_features AS pf 
  INNER JOIN cscart_product_features_descriptions AS pfd ON pf.feature_id = pfd.feature_id 
  AND pfd.lang_code = 'vi' 
WHERE 
  pf.feature_id IN (
    22556, 21429, 24624, 23249, 23250, 21722, 
    21721, 21912, 21426, 21430, 19826, 
    24952, 20599, 21217, 20380, 24214, 
    20604, 23648, 23649, 23148, 21913, 
    20608
  ) 
ORDER BY 
  purpose_position ASC, 
  pf.position ASC, 
  pf.feature_id ASC

Query time 0.00442

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "read_sorted_file": {
          "filesort": {
            "sort_key": "case when pf.purpose = 'group_catalog_item' then 0 else 1 end, pf.position, pf.feature_id",
            "table": {
              "table_name": "pf",
              "access_type": "range",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["feature_id"],
              "rows": 22,
              "filtered": 100,
              "index_condition": "pf.feature_id in (22556,21429,24624,23249,23250,21722,21721,21912,21426,21430,19826,24952,20599,21217,20380,24214,20604,23648,23649,23148,21913,20608)"
            }
          }
        }
      },
      {
        "table": {
          "table_name": "pfd",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "9",
          "used_key_parts": ["feature_id", "lang_code"],
          "ref": ["dev_db.pf.feature_id", "const"],
          "rows": 1,
          "filtered": 100,
          "index_condition": "pfd.lang_code = 'vi'"
        }
      }
    ]
  }
}

Result

feature_id feature_style position purpose display_on_catalog description internal_name prefix suffix purpose_position
19826 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
20380 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
20599 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
20604 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
20608 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
21217 dropdown_labels 0 group_variation_catalog_item N Chọn bìa sổ Chọn bìa sổ 1
21426 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
21429 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
21430 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
21721 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
21722 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
21912 dropdown_labels 0 group_variation_catalog_item N Lựa chọn thiết kế Lựa chọn thiết kế 1
21913 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
22556 dropdown_labels 0 group_variation_catalog_item N Lựa chọn Lựa chọn 1
23148 dropdown_labels 0 group_variation_catalog_item N Chọn mẫu 10406_14 1
23249 dropdown_labels 0 group_variation_catalog_item N Chọn kích cỡ búp bê 10615_12 - size 1
23250 dropdown_labels 0 group_variation_catalog_item N Chọn màu búp bê 10615_12 - màu 1
23648 dropdown_labels 0 group_variation_catalog_item N Chọn màu 10199_14 - màu 1
23649 dropdown_labels 0 group_variation_catalog_item N Chọn sản phẩm 10199_14 - sản phẩm 1
24214 dropdown_labels 0 group_variation_catalog_item N Lựa chọn 10328_01 - gram 1
24624 dropdown_labels 0 group_variation_catalog_item N Lựa chọn 10456_78 - option 1
24952 dropdown_labels 0 group_variation_catalog_item N Tùy chọn Tùy chọn 1