" receiving method setValue(txt) ? ?" />
M
M
MAXH02014-09-22 14:43:58
MySQL
MAXH0, 2014-09-22 14:43:58

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

8 answer(s)
E
Evgeny Bukharev, 2016-09-22
@evgenybuckharev

EXPLAIN SELECT product_id FROM( ....

D
Dmitry Entelis, 2016-09-22
@DmitriyEntelis

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)

write
JOIN oc_product_attribute p2a0 ON (p2a0.product_id=p.product_id and p2a0.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%')

Please note that I refer to the p table - it already has a product_id
And make sure that there is an index in oc_product_attribute (product_id, attribute_id, text)
Next:
A good way to optimize queries is to split them into several, in this case it is quite possible.
6 requests of the form
select product_id from oc_product_attribute p2a0 where (p2a0.product_id=p.product_id and p2a0.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%')

Next, in the PL, we select the product_id that is in all 6 samples.
Farther
select * from oc_product  where product_id IN (1,2,3 ...)

E
Evgeny Svirsky, 2016-09-22
@e_svirsky

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.

E
Edward, 2016-09-22
@edb

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 '%ЛПО%'
               )

this way you get rid of distinct
if there is no index on attribute_id yet, create it.
3. You don't need to use a subquery. This is redundant
4. Leave only product_id in the select
This is all that can be said only on request. Everything else will be guesswork on the coffee grounds. However, this, too, can all be a finger in the sky :)

E
evnuh, 2016-09-22
@evnuh

Subquery, distinct, joins, fuzzy search with %%, sort by expression, limit - yes, this is the worst situation that can be imagined for a relational subd.

U
un1t, 2016-09-22
@un1t

Are you sure you need view queries?
p2a0.text LIKE '%LPO%'
Is that enough?
p2a0.text LIKE 'LPO'

I
idShura, 2016-09-23
@idShura

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

S
shagguboy, 2016-09-23
@shagguboy

throw out left joins because they do not affect anything

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question