Paradigma
Новичок
Есть данные в таблице где более 500 000 зыписей, так вот, я понимаю в принципе где проблема, но не понимаю как правильно её решить, вот запрос, которые выполняется 0,2 сек
SELECT DISTINCT commerce_order.order_id AS order_id
FROM commerce_order commerce_order
LEFT JOIN field_data_commerce_customer_billing field_data_commerce_customer_billing ON
commerce_order.order_id = field_data_commerce_customer_billing.entity_id
LEFT JOIN field_data_commerce_customer_traveler field_data_commerce_customer_traveler ON
commerce_order.order_id = field_data_commerce_customer_traveler.entity_id AND (field_data_commerce_customer_traveler.entity_type = 'commerce_order' AND field_data_commerce_customer_traveler.deleted = '0')
LEFT JOIN field_data_field_billing_first_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.deleted = '0')
LEFT JOIN field_data_field_first_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.deleted = '0')
LEFT JOIN field_data_field_billing_last_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.deleted = '0')
LEFT JOIN field_data_field_last_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.deleted = '0')
WHERE ((
(CONCAT_WS(' ', commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.field_billing_last_name_value,
' ', commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.field_last_name_value) LIKE '%Mat%')))
GROUP BY order_id
ORDER BY order_id DESC
LIMIT 31 OFFSET 0;
а вот запрос которые выполняется 5 секунд
SELECT DISTINCT commerce_order.order_id AS order_id
FROM commerce_order commerce_order
LEFT JOIN field_data_commerce_customer_billing field_data_commerce_customer_billing ON
commerce_order.order_id = field_data_commerce_customer_billing.entity_id
LEFT JOIN field_data_commerce_customer_traveler field_data_commerce_customer_traveler ON
commerce_order.order_id = field_data_commerce_customer_traveler.entity_id AND (field_data_commerce_customer_traveler.entity_type = 'commerce_order' AND field_data_commerce_customer_traveler.deleted = '0')
LEFT JOIN field_data_field_billing_first_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.deleted = '0')
LEFT JOIN field_data_field_first_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.deleted = '0')
LEFT JOIN field_data_field_billing_last_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.deleted = '0')
LEFT JOIN field_data_field_last_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.deleted = '0')
WHERE (((CONCAT_WS(' ', commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.field_billing_first_name_value,
' ', commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.field_first_name_value) LIKE '%Erik%') AND
(CONCAT_WS(' ', commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.field_billing_last_name_value,
' ', commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.field_last_name_value) LIKE '%Mat%')))
GROUP BY order_id
ORDER BY order_id DESC
LIMIT 31 OFFSET 0;
я понимаю что ему приходится уже искать не по одной таблице, а по двум значения, но как-то ведь можно решить проблему?
тип таблиц InnoDB индексы есть
SELECT DISTINCT commerce_order.order_id AS order_id
FROM commerce_order commerce_order
LEFT JOIN field_data_commerce_customer_billing field_data_commerce_customer_billing ON
commerce_order.order_id = field_data_commerce_customer_billing.entity_id
LEFT JOIN field_data_commerce_customer_traveler field_data_commerce_customer_traveler ON
commerce_order.order_id = field_data_commerce_customer_traveler.entity_id AND (field_data_commerce_customer_traveler.entity_type = 'commerce_order' AND field_data_commerce_customer_traveler.deleted = '0')
LEFT JOIN field_data_field_billing_first_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.deleted = '0')
LEFT JOIN field_data_field_first_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.deleted = '0')
LEFT JOIN field_data_field_billing_last_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.deleted = '0')
LEFT JOIN field_data_field_last_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.deleted = '0')
WHERE ((
(CONCAT_WS(' ', commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.field_billing_last_name_value,
' ', commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.field_last_name_value) LIKE '%Mat%')))
GROUP BY order_id
ORDER BY order_id DESC
LIMIT 31 OFFSET 0;
а вот запрос которые выполняется 5 секунд
SELECT DISTINCT commerce_order.order_id AS order_id
FROM commerce_order commerce_order
LEFT JOIN field_data_commerce_customer_billing field_data_commerce_customer_billing ON
commerce_order.order_id = field_data_commerce_customer_billing.entity_id
LEFT JOIN field_data_commerce_customer_traveler field_data_commerce_customer_traveler ON
commerce_order.order_id = field_data_commerce_customer_traveler.entity_id AND (field_data_commerce_customer_traveler.entity_type = 'commerce_order' AND field_data_commerce_customer_traveler.deleted = '0')
LEFT JOIN field_data_field_billing_first_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.deleted = '0')
LEFT JOIN field_data_field_first_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.deleted = '0')
LEFT JOIN field_data_field_billing_last_name commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name ON
field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.deleted = '0')
LEFT JOIN field_data_field_last_name commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name ON
field_data_commerce_customer_traveler.commerce_customer_traveler_profile_id = commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_id AND (commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.entity_type = 'commerce_customer_profile' AND commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.deleted = '0')
WHERE (((CONCAT_WS(' ', commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_first_name.field_billing_first_name_value,
' ', commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_first_name.field_first_name_value) LIKE '%Erik%') AND
(CONCAT_WS(' ', commerce_customer_profile_field_data_commerce_customer_billing__field_data_field_billing_last_name.field_billing_last_name_value,
' ', commerce_customer_profile_field_data_commerce_customer_traveler__field_data_field_last_name.field_last_name_value) LIKE '%Mat%')))
GROUP BY order_id
ORDER BY order_id DESC
LIMIT 31 OFFSET 0;
я понимаю что ему приходится уже искать не по одной таблице, а по двум значения, но как-то ведь можно решить проблему?
тип таблиц InnoDB индексы есть