Добрый вечер. уважаемые гуру!
Сейчас покажу на 99% очень кривой запрос.
SELECT items.id,
items.name,
items.icon_name,
items.quality,
items.level,
items.warrior,
items.warrior_max,
items.usable_rank_min,
items.craft_recipe_info,
items.item_type,
items.soul_bind,
items.hit_count,
items.min_damage,
items.max_damage,
items.hit_accuracy,
items.critical,
items.parry,
items.magical_skill_boost,
items.magical_skill_boost_resist,
items.magical_hit_accuracy,
items.attack_delay,
items.dodge,
items.magical_resist,
items.physical_defend,
items.block,
items.damage_reduce,
items.bonus_attr1,
items.bonus_attr2,
items.bonus_attr3,
items.bonus_attr4,
items.bonus_attr5,
items.bonus_attr6,
items.bonus_attr7,
items.bonus_attr8,
items.bonus_attr9,
items.bonus_attr10,
items.bonus_attr11,
items.bonus_attr12,
items.charge_level,
items.bonus_attr_a1,
items.bonus_attr_a2,
items.bonus_attr_a3,
items.bonus_attr_a4,
items.bonus_attr_b1,
items.bonus_attr_b2,
items.bonus_attr_b3,
items.bonus_attr_b4,
items.max_enchant_value,
items.abyss_point,
a_coins.id AS `a_coins_id`,
a_coins.icon_name AS `a_coin_icon`,
items.abyss_item_count,
d_a_coins.body AS `desc_a_coin`,
ex_coins.id AS `ex_coins_id`,
ex_coins.icon_name AS `ex_coin_icon`,
items.extra_currency_item_count,
d_ex_coins.body AS `desc_ex_coin`,
items.trade_in_item_list,
items.can_exchange,
items.can_sell_to_npc,
items.can_deposit_to_account_warehouse,
items.can_deposit_to_guild_warehouse,
items.no_enchant,
items.cannot_changeskin,
items.cannot_extraction,
items.can_proc_enchant,
items.extract_skin_type,
items.race_permitted,
items.option_slot_value,
items.option_slot_bonus,
items.use_delay,
rus.body,
recipe.combineskill,
recipe.require_dp,
recipe.required_skillpoint,
recipe.component_quantity,
recipe.component1,
recipe.compo1_quantity,
comp_1.id AS `compo1_id`,
comp_1.icon_name AS `compo1_icon`,
comp_1.quality AS `compo1_quality`,
recipe.component2,
recipe.compo2_quantity,
comp_2.id AS `compo2_id`,
comp_2.icon_name AS `compo2_icon`,
comp_2.quality AS `compo2_quality`,
recipe.component3,
recipe.compo3_quantity,
comp_3.id AS `compo3_id`,
comp_3.icon_name AS `compo3_icon`,
comp_3.quality AS `compo3_quality`,
recipe.component4,
recipe.compo4_quantity,
comp_4.id AS `compo4_id`,
comp_4.icon_name AS `compo4_icon`,
comp_4.quality AS `compo4_quality`,
recipe.component5,
recipe.compo5_quantity,
comp_5.id AS `compo5_id`,
comp_5.icon_name AS `compo5_icon`,
comp_5.quality AS `compo5_quality`,
recipe.component6, recipe.compo6_quantity,
comp_6.id AS `compo6_id`,
comp_6.icon_name AS `compo6_icon`,
comp_6.quality AS `compo6_quality`,
recipe.component7,
recipe.compo7_quantity,
comp_7.id AS `compo7_id`,
comp_7.icon_name AS `compo7_icon`,
comp_7.quality AS `compo7_quality`,
recipe.component8,
recipe.compo8_quantity,
comp_8.id AS `compo8_id`,
comp_8.icon_name AS `compo8_icon`,
comp_8.quality AS `compo8_quality`,
recipe.product,
prod.id AS `prod_id_0`,
prod.quality AS `prod_quality_0`,
prod.icon_name AS `prod_icon`,
product_des.body AS `prod_name`,
prod_1.id AS `prod_id_1`,
prod_1.quality AS `prod_quality_1`,
prod_1.icon_name AS `prod1_icon`,
product1_des.body AS `prod1_name`,
prod_2.id AS `prod_id_2`,
prod_2.quality AS `prod_quality_2`,
prod_2.icon_name AS `prod2_icon`,
product2_des.body AS `prod2_name`,
prod_3.id AS `prod_id_3`,
prod_3.quality AS `prod_quality_3`,
prod_3.icon_name AS `prod3_icon`,
product3_des.body AS `prod3_name`,
recipe.combo1_product,
recipe.combo2_product,
recipe.combo3_product,
craft_1.body AS `rec_desc_1`,
craft_2.body AS `rec_desc_2`,
craft_3.body AS `rec_desc_3`,
craft_4.body AS `rec_desc_4`,
craft_5.body AS `rec_desc_5`,
craft_6.body AS `rec_desc_6`,
craft_7.body AS `rec_desc_7`,
craft_8.body AS `rec_desc_8`,
setitem.name AS `set_id`,
set_desc.body AS `setname`,
setitem_1.body AS s_i_name_1,
setitem_2.body AS s_i_name_2,
setitem_3.body AS s_i_name_3,
setitem_4.body AS s_i_name_4,
setitem_5.body AS s_i_name_5,
setitem_6.body AS s_i_name_6,
setitem_7.body AS s_i_name_7,
setitem_8.body AS s_i_name_8,
setitem_9.body AS s_i_name_9,
setitem_10.body AS s_i_name_10,
setitem_11.body AS s_i_name_11,
setitem_12.body AS s_i_name_12,
setitem_13.body AS s_i_name_13,
setitem.item1,
setitem.item2,
setitem.item3,
setitem.item4,
setitem.item5,
setitem.item6,
setitem.item7,
setitem.item8,
setitem.item9,
setitem.item10,
setitem.item11,
setitem.item12,
setitem.item13,
setitem.piece_bonus2,
setitem.piece_bonus3,
setitem.piece_bonus4,
setitem.piece_bonus5,
setitem.piece_bonus6,
setitem.fullset_bonus,
info.body AS `str_desc`,
items.activation_skill,
items.activation_level,
skill.name AS `skill_name`,
skill.effect1_type,
skill.effect1_checktime,
skill.effect1_remain2,
skill.effect1_reserved1,
skill.effect1_reserved2,
skill.effect1_reserved4,
skill.effect1_reserved7,
skill.effect1_reserved8,
skill.effect1_reserved9,
skill.effect1_reserved12,
skill.effect1_reserved13,
skill.effect1_reserved14,
skill.effect2_type,
skill.effect2_checktime,
skill.effect2_remain2,
skill.effect2_reserved1,
skill.effect2_reserved2,
skill.effect2_reserved4,
skill.effect2_reserved7,
skill.effect2_reserved8,
skill.effect2_reserved9,
skill.effect2_reserved12,
skill.effect2_reserved13,
skill.effect2_reserved14,
skill.effect3_type,
skill.effect3_checktime,
skill.effect3_remain2,
skill.effect3_reserved1,
skill.effect3_reserved2,
skill.effect3_reserved4,
skill.effect3_reserved7,
skill.effect3_reserved8,
skill.effect3_reserved9,
skill.effect3_reserved12,
skill.effect3_reserved13,
skill.effect3_reserved14,
skill.effect4_type,
skill.effect4_checktime,
skill.effect4_remain2,
skill.effect4_reserved1,
skill.effect4_reserved2,
skill.effect4_reserved4,
skill.effect4_reserved7,
skill.effect4_reserved8,
skill.effect4_reserved9,
skill.effect4_reserved12,
skill.effect4_reserved13,
skill.effect4_reserved14
FROM items
INNER JOIN rus ON items.desc_name = rus.name
LEFT JOIN recipe ON items.craft_recipe_info = recipe.name
LEFT JOIN rus AS `info` ON items.desc_long = info.name
LEFT JOIN items AS `comp_1` ON recipe.component1 = comp_1.name
LEFT JOIN rus AS `craft_1` ON comp_1.desc_name = craft_1.name
LEFT JOIN items AS `comp_2` ON comp_2.name = recipe.component2
LEFT JOIN rus AS `craft_2` ON comp_2.desc_name = craft_2.name
LEFT JOIN items AS `comp_3` ON comp_3.name = recipe.component3
LEFT JOIN rus AS `craft_3` ON comp_3.desc_name = craft_3.name
LEFT JOIN items AS `comp_4` ON comp_4.name = recipe.component4
LEFT JOIN rus AS `craft_4` ON comp_4.desc_name = craft_4.name
LEFT JOIN items AS `comp_5` ON comp_5.name = recipe.component5
LEFT JOIN rus AS `craft_5` ON comp_5.desc_name = craft_5.name
LEFT JOIN items AS `comp_6` ON comp_6.name = recipe.component6
LEFT JOIN rus AS `craft_6` ON comp_6.desc_name = craft_6.name
LEFT JOIN items AS `comp_7` ON comp_7.name = recipe.component7
LEFT JOIN rus AS `craft_7` ON comp_7.desc_name = craft_7.name
LEFT JOIN items AS `comp_8` ON comp_8.name = recipe.component8
LEFT JOIN rus AS `craft_8` ON comp_8.desc_name = craft_8.name
LEFT JOIN items AS `prod` ON prod.name = recipe.product
LEFT JOIN rus AS `product_des` ON product_des.name = prod.desc_name
LEFT JOIN items AS `prod_1` ON prod_1.name = recipe.combo1_product
LEFT JOIN rus AS `product1_des` ON product1_des.name = prod_1.desc_name
LEFT JOIN items AS `prod_2` ON prod_2.name = recipe.combo2_product
LEFT JOIN rus AS `product2_des` ON product2_des.name = prod_2.desc_name
LEFT JOIN items AS `prod_3` ON prod_3.name = recipe.combo3_product
LEFT JOIN rus AS `product3_des` ON product3_des.name = prod_3.desc_name
LEFT JOIN setitem ON setitem.name = items.set_item_name
LEFT JOIN rus AS `set_desc` ON setitem.desc_name = set_desc.name
LEFT JOIN items AS `set_item_1` ON set_item_1.name = setitem.item1
LEFT JOIN rus AS `setitem_1` ON setitem_1.name = set_item_1.desc_name
LEFT JOIN items AS `set_item_2` ON set_item_2.name = setitem.item2
LEFT JOIN rus AS `setitem_2` ON setitem_2.name = set_item_2.desc_name
LEFT JOIN items AS `set_item_3` ON set_item_3.name = setitem.item3
LEFT JOIN rus AS `setitem_3` ON setitem_3.name = set_item_3.desc_name
LEFT JOIN items AS `set_item_4` ON set_item_4.name = setitem.item4
LEFT JOIN rus AS `setitem_4` ON setitem_4.name = set_item_4.desc_name
LEFT JOIN items AS `set_item_5` ON set_item_5.name = setitem.item5
LEFT JOIN rus AS `setitem_5` ON setitem_5.name = set_item_5.desc_name
LEFT JOIN items AS `set_item_6` ON set_item_6.name = setitem.item6
LEFT JOIN rus AS `setitem_6` ON setitem_6.name = set_item_6.desc_name
LEFT JOIN items AS `set_item_7` ON set_item_7.name = setitem.item7
LEFT JOIN rus AS `setitem_7` ON setitem_7.name = set_item_7.desc_name
LEFT JOIN items AS `set_item_8` ON set_item_8.name = setitem.item8
LEFT JOIN rus AS `setitem_8` ON setitem_8.name = set_item_8.desc_name
LEFT JOIN items AS `set_item_9` ON set_item_9.name = setitem.item9
LEFT JOIN rus AS `setitem_9` ON setitem_9.name = set_item_9.desc_name
LEFT JOIN items AS `set_item_10` ON set_item_10.name = setitem.item10
LEFT JOIN rus AS `setitem_10` ON setitem_10.name = set_item_10.name
LEFT JOIN items AS `set_item_11` ON set_item_11.name = setitem.item11
LEFT JOIN rus AS `setitem_11` ON setitem_11.name = set_item_11.desc_name
LEFT JOIN items AS `set_item_12` ON set_item_12.name = setitem.item12
LEFT JOIN rus AS `setitem_12` ON setitem_12.name = set_item_12.desc_name
LEFT JOIN items AS `set_item_13` ON set_item_13.name = setitem.item13
LEFT JOIN rus AS `setitem_13` ON setitem_13.name = set_item_13.desc_name
LEFT JOIN items AS `a_coins` ON a_coins.name = items.abyss_item
LEFT JOIN rus AS `d_a_coins` ON d_a_coins.name = a_coins.desc_name
LEFT JOIN items AS `ex_coins` ON ex_coins.name = items.extra_currency_item
LEFT JOIN rus AS `d_ex_coins` ON d_ex_coins.name = ex_coins.desc_name
LEFT JOIN skill ON skill.name = items.activation_skill
WHERE (items.id LIKE '1000_%') AND items.quality IN ('epic', 'mythic') AND (items.level >= 60 AND items.level <= 65) ORDER BY items.level
Его EXPLAIN приклеенном txt-файле.
В таблицах не более 100 000 записей.
Данный запрос выполняется за 0,2 сек на моем импровизированном "сервере" из старого ноутбука, с процессором Semprom 1.7Gh
и 512 оперативы.
Я бы собственно и дальше пролжал наращивать сей запрос JOIN'ами, но MySQL на меня обиделся когда ярешил присать еще 2 JOIN'a, сказав что максимум 61 таблица и все.
Внимание вопрос, это как-то вообще можно оптимизировать?
Отредактированно Monstr (14.01.2013 19:33:43)
Прикрепленные файлы:
explain.txt, Размер: 6,019 байт, Скачано: 1,133