demis
Новичок
Оптимизация запроса
у меня такой запрос
SELECT id, name, idheaders, type1, type2, type3
FROM grandi_catalog
WHERE (
idp =1 OR idp =2 OR idp =3 OR idp =14 OR idp =344 OR idp =361 OR idp =378 OR idp =418 OR idp =435 OR idp =452 OR idp =492 OR idp =509 OR idp =526 OR idp =566 OR idp =583 OR idp =600 OR idp =640 OR idp =657 OR idp =674 OR idp =714 OR idp =731 OR idp =748 OR idp =788 OR idp =805 OR idp =822 OR idp =862 OR idp =879 OR idp =896 OR idp =936 OR idp =953 OR idp =970 OR idp =1010 OR idp =1027 OR idp =1044 OR idp =1084 OR idp =1101 OR idp =1118 OR idp =1158 OR idp =1175 OR idp =1192 OR idp =1232 OR idp =1249 OR idp =1266 OR idp =1306 OR idp =1323 OR idp =1340 OR idp =1380 OR idp =1397 OR idp =1414 OR idp =1454 OR idp =1471 OR idp =1488 OR idp =1528 OR idp =1545 OR idp =1562 OR idp =1602 OR idp =1619 OR idp =1636 OR idp =1676 OR idp =1693 OR idp =1710 OR idp =1750 OR idp =1767 OR idp =1784 OR idp =3158 OR idp =3175 OR idp =3192 OR idp =4566 OR idp =4583 OR idp =4600 OR idp =5974 OR idp =5991 OR idp =6008 OR idp =7382 OR idp =7399 OR idp =7416 OR idp =8790 OR idp =8807 OR idp =8824 OR idp =30 OR idp =131 OR idp =315 OR idp =316 OR idp =390 OR idp =464 OR idp =538 OR idp =612 OR idp =686 OR idp =760 OR idp =834 OR idp =908 OR idp =982 OR idp =1056 OR idp =1130 OR idp =1204 OR idp =1278 OR idp =1352 OR idp =1426 OR idp =1500 OR idp =1574 OR idp =1648 OR idp =1722 OR idp =1796 OR idp =3204 OR idp =4612 OR idp =6020 OR idp =7428 OR idp =8836 OR idp =32 OR idp =33 OR idp =39 OR idp =45 OR idp =46 OR idp =59 OR idp =73 OR idp =83 OR idp =89 OR idp =256 OR idp =270 OR idp =96 OR idp =157 OR idp =158 OR idp =180 OR idp =287 OR idp =295 OR idp =312 OR 0
) AND isprod =1 AND hide =0
GROUP BY name, type1, type2, type3
ORDER BY sort
LIMIT 0 , 20
выполняется 0.25 секунд
кол-во записей в таблице 9465
хотелось бы быстрее, возможно ли это и не страшны ли запросы такого вида?
explain говорит
table type possible_keys key key_len ref rows Extra
grandi_catalog ALL idp,idp_2 NULL NULL NULL 9465 Using where; Using temporary; Using filesort
перепробывал по всякому индексы, ничего лучше не получаеться, может найдеться совет у кого?
у меня такой запрос
SELECT id, name, idheaders, type1, type2, type3
FROM grandi_catalog
WHERE (
idp =1 OR idp =2 OR idp =3 OR idp =14 OR idp =344 OR idp =361 OR idp =378 OR idp =418 OR idp =435 OR idp =452 OR idp =492 OR idp =509 OR idp =526 OR idp =566 OR idp =583 OR idp =600 OR idp =640 OR idp =657 OR idp =674 OR idp =714 OR idp =731 OR idp =748 OR idp =788 OR idp =805 OR idp =822 OR idp =862 OR idp =879 OR idp =896 OR idp =936 OR idp =953 OR idp =970 OR idp =1010 OR idp =1027 OR idp =1044 OR idp =1084 OR idp =1101 OR idp =1118 OR idp =1158 OR idp =1175 OR idp =1192 OR idp =1232 OR idp =1249 OR idp =1266 OR idp =1306 OR idp =1323 OR idp =1340 OR idp =1380 OR idp =1397 OR idp =1414 OR idp =1454 OR idp =1471 OR idp =1488 OR idp =1528 OR idp =1545 OR idp =1562 OR idp =1602 OR idp =1619 OR idp =1636 OR idp =1676 OR idp =1693 OR idp =1710 OR idp =1750 OR idp =1767 OR idp =1784 OR idp =3158 OR idp =3175 OR idp =3192 OR idp =4566 OR idp =4583 OR idp =4600 OR idp =5974 OR idp =5991 OR idp =6008 OR idp =7382 OR idp =7399 OR idp =7416 OR idp =8790 OR idp =8807 OR idp =8824 OR idp =30 OR idp =131 OR idp =315 OR idp =316 OR idp =390 OR idp =464 OR idp =538 OR idp =612 OR idp =686 OR idp =760 OR idp =834 OR idp =908 OR idp =982 OR idp =1056 OR idp =1130 OR idp =1204 OR idp =1278 OR idp =1352 OR idp =1426 OR idp =1500 OR idp =1574 OR idp =1648 OR idp =1722 OR idp =1796 OR idp =3204 OR idp =4612 OR idp =6020 OR idp =7428 OR idp =8836 OR idp =32 OR idp =33 OR idp =39 OR idp =45 OR idp =46 OR idp =59 OR idp =73 OR idp =83 OR idp =89 OR idp =256 OR idp =270 OR idp =96 OR idp =157 OR idp =158 OR idp =180 OR idp =287 OR idp =295 OR idp =312 OR 0
) AND isprod =1 AND hide =0
GROUP BY name, type1, type2, type3
ORDER BY sort
LIMIT 0 , 20
выполняется 0.25 секунд
кол-во записей в таблице 9465
хотелось бы быстрее, возможно ли это и не страшны ли запросы такого вида?
explain говорит
table type possible_keys key key_len ref rows Extra
grandi_catalog ALL idp,idp_2 NULL NULL NULL 9465 Using where; Using temporary; Using filesort
перепробывал по всякому индексы, ничего лучше не получаеться, может найдеться совет у кого?