Answer the question
In order to leave comments, you need to log in
" receiving method setValue(txt) ? ?" />
Why doesn't CodeMirror convert "<" and ">" receiving method setValue(txt) ? ?
BUT getting from textarea - everything is fine.
txt is loaded dynamically from a file.
Is there a separate flag for it to convert?
Or just run txt through a regular expression?
Answer the question
In order to leave comments, you need to log in
Tin actually ;-)
Look, let's start with the fact that each join is a product of matrices. It makes sense to kill the join condition as much as possible, instead of
LEFT JOIN oc_product_attribute p2a0 ON (p2a0.product_id=p2a.product_id)
JOIN oc_product_attribute p2a0 ON (p2a0.product_id=p.product_id and p2a0.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%')
select product_id from oc_product_attribute p2a0 where (p2a0.product_id=p.product_id and p2a0.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%')
select * from oc_product where product_id IN (1,2,3 ...)
You need to determine which LEFT JOIN your query is valid for. Then check - indexes, if not, do it. If there is, then think about adding redundancy. Still here a problem in LIKE. Maybe it makes sense to use which search engine, Elastic, Sphinx.
1. replace all left joins with inner joins. This will not necessarily bring performance automatically, but it will be more correct. Because AND cp.path_id IN (3558) makes all "left join" "inner join".
2. remove all oc_product_attribute connections from "FROM", and replace conditions in where for these tables with exists, for example:
and exists (select *
from oc_product_attribute a
where a.product_id=p2a.product_id
and a.attribute_id = 12
and a.text LIKE '%ЛПО%'
)
Subquery, distinct, joins, fuzzy search with %%, sort by expression, limit - yes, this is the worst situation that can be imagined for a relational subd.
Are you sure you need view queries?
p2a0.text LIKE '%LPO%'
Is that enough?
p2a0.text LIKE 'LPO'
You can try like this (+ what was advised above):
SELECT product_id FROM(
SELECT DISTINCT p.product_id, pd.name, p.model, p.quantity, p.price, p.sort_order, p.date_added , p.price as realprice
FROM oc_product p
LEFT JOIN oc_product_option_value pov ON pov.product_id = p.product_id
LEFT JOIN oc_product_description pd ON pd.product_id = p.product_id
LEFT JOIN oc_product_to_store p2s ON p2s.product_id = p.product_id
LEFT JOIN oc_product_to_category p2c ON p2c.product_id = p.product_id
LEFT JOIN oc_category_path cp ON cp.category_id = p2c.category_id
LEFT JOIN oc_product_attribute p2 ON p2.product_id = p.product_id
WHERE 1 AND cp.path_id IN (3558)
AND (
(p2.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%') OR
(p2a1.attribute_id = 20 AND p2a1.text LIKE '%2х36 Вт%') OR
(p2a2.attribute_id = 22 AND p2a2.text LIKE '%накладны%') OR
(p2a3.attribute_id = 27 AND p2a3.text LIKE '%60 см%') OR
(p2a4.attribute_id = 29 AND p2a4.text LIKE '%T8%') OR
(p2a5.attribute_id = 30 AND p2a5.text LIKE '%220 В%')
)
AND pd.language_id = '1' AND p.status = '1' AND p2s.store_id = 0) as innertable
WHERE 1 ORDER BY sort_order ASC, LCASE(name) ASC LIMIT 0,20
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question