SELECT 
  jmj_payments.*, 
  jmj_payment_descriptions.*, 
  IF (
    ISNULL(jmj_addons.status), 
    "A", 
    jmj_addons.status
  ) AS processor_status, 
  jmj_payment_processors.type AS processor_type, 
  jmj_payment_processors.processor_script AS processor_script 
FROM 
  jmj_payments 
  LEFT JOIN jmj_payment_descriptions ON jmj_payment_descriptions.payment_id = jmj_payments.payment_id 
  AND jmj_payment_descriptions.lang_code = 'en' 
  LEFT JOIN jmj_payment_processors ON jmj_payment_processors.processor_id = jmj_payments.processor_id 
  LEFT JOIN jmj_addons ON jmj_payment_processors.addon = jmj_addons.addon 
  LEFT JOIN jmj_storefronts_payments AS storefronts_payments ON storefronts_payments.payment_id = jmj_payments.payment_id 
WHERE 
  jmj_payments.status = 'A' 
  AND (
    jmj_payments.usergroup_ids = '' 
    OR FIND_IN_SET(0, jmj_payments.usergroup_ids) 
    OR FIND_IN_SET(1, jmj_payments.usergroup_ids)
  ) 
  AND (
    storefronts_payments.storefront_id = 1 
    OR storefronts_payments.storefront_id IS NULL
  ) 
HAVING 
  processor_status = 'A' 
ORDER BY 
  jmj_payments.position

Query time 0.01178

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "5.90"
    },
    "ordering_operation": {
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "1.00"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "storefronts_payments",
            "access_type": "system",
            "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": "16"
            },
            "used_columns": [
              "storefront_id",
              "payment_id"
            ]
          }
        },
        {
          "table": {
            "table_name": "jmj_payments",
            "access_type": "ALL",
            "possible_keys": [
              "c_status"
            ],
            "rows_examined_per_scan": 10,
            "rows_produced_per_join": 1,
            "filtered": "10.00",
            "cost_info": {
              "read_cost": "4.10",
              "eval_cost": "0.20",
              "prefix_cost": "4.30",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "payment_id",
              "company_id",
              "usergroup_ids",
              "position",
              "status",
              "template",
              "processor_id",
              "processor_params",
              "a_surcharge",
              "p_surcharge",
              "tax_ids",
              "localization",
              "payment_category"
            ],
            "attached_condition": "((`jmj_test`.`jmj_payments`.`status` = 'A') and ((`jmj_test`.`jmj_payments`.`usergroup_ids` = '') or find_in_set(0,`jmj_test`.`jmj_payments`.`usergroup_ids`) or find_in_set(1,`jmj_test`.`jmj_payments`.`usergroup_ids`)))"
          }
        },
        {
          "table": {
            "table_name": "jmj_payment_descriptions",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "payment_id",
              "lang_code"
            ],
            "key_length": "9",
            "ref": [
              "jmj_test.jmj_payments.payment_id",
              "const"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.00",
              "eval_cost": "0.20",
              "prefix_cost": "4.50",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "payment_id",
              "payment",
              "description",
              "instructions",
              "surcharge_title",
              "lang_code"
            ]
          }
        },
        {
          "table": {
            "table_name": "jmj_payment_processors",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "processor_id"
            ],
            "key_length": "3",
            "ref": [
              "jmj_test.jmj_payments.processor_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.00",
              "eval_cost": "0.20",
              "prefix_cost": "4.70",
              "data_read_per_join": "3K"
            },
            "used_columns": [
              "processor_id",
              "processor_script",
              "type",
              "addon"
            ]
          }
        },
        {
          "table": {
            "table_name": "jmj_addons",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "addon"
            ],
            "key_length": "98",
            "ref": [
              "jmj_test.jmj_payment_processors.addon"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.00",
              "eval_cost": "0.20",
              "prefix_cost": "4.90",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "addon",
              "status"
            ]
          }
        }
      ]
    }
  }
}

Result

payment_id company_id usergroup_ids position status template processor_id processor_params a_surcharge p_surcharge tax_ids localization payment_category payment description instructions surcharge_title lang_code processor_status processor_type processor_script
14 0 0 0 A views/orders/components/payments/cc_outside.tpl 105 a:14:{s:8:"currency";s:3:"INR";s:6:"layout";s:9:"templateA";s:12:"payflowcolor";s:0:"";s:12:"header_image";s:0:"";s:14:"button_bgcolor";s:0:"";s:17:"button_text_color";s:0:"";s:17:"collapse_bg_color";s:0:"";s:19:"collapse_text_color";s:0:"";s:16:"label_text_color";s:0:"";s:14:"merchant_login";s:0:"";s:8:"api_user";s:0:"";s:11:"api_partner";s:0:"";s:12:"api_password";s:0:"";s:4:"mode";s:4:"test";} 0.000 0.000 tab1 PayPal Advanced en A P paypal_advanced.php
2 0 0,11 40 A views/orders/components/payments/phone.tpl 0 0.000 0.000 tab3 Phone ordering Call 011-66281100 <h2>When I should use phone ordering?</h2> <p>Order by phone is useful when regular payment methods like credit card are unavailable or considered insecure.</p> <p>Our operators are happy to take your order per phone every business day from 9 a.m. to 5 p.m. UTC.</p> en A
5 0 0 50 A views/orders/components/payments/money.tpl 0 0.000 0.000 tab3 Money Order US Banks Only Type instructions to pay by visiting your retail store in here. en A