Answer the question
In order to leave comments, you need to log in
What is the correct way to do PARTITION in MySQL?
There are tables of records with 6 million records, even simple selections are slow. Each entry has a city column (120 cities) should it be split into cities ? And in general, will partitioning help for optimization?
SELECT distinct(product.id), product.id,
product.name,
product.description,
product.city_id,
product.price,
product.company_name,
product.timestamp_update,
product.company_id,
city.name as city_name
FROM `product_to_tag` `v2t`
JOIN `product` ON product.id = v2t.product_id
JOIN `product_to_city` `vtc` ON product.id = vtc.product_id
JOIN `city` `c` ON c.id = vtc.city_id
LEFT JOIN `city` `city` ON city.id=product.city_id
LEFT JOIN `company` ON company.id=product.company_id
WHERE ((`product`.`publish` = 1)) AND (product.id != 5016460) AND (c.id = 99 or c.parent_id = 99) AND ((`v2t`.`tag_id` IN (65, 181, 228, 1135)))
ORDER BY `product`.`timestamp_update` DESC LIMIT 30;
Answer the question
In order to leave comments, you need to log in
6M is not enough. It is necessary not to partition the table, but to write the query correctly and, possibly, build indexes.
https://dev.mysql.com/doc/refman/5.7/en/explain.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question