0
以下查询效率不高,我需要使其运行速度更快。查询检查太多行,我该如何减少?
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY sob_datas ALL sob_form_id,sob_form_id_2 NULL NULL NULL 365990 Using where
2 DEPENDENT SUBQUERY sub_sob_datas ALL sob_form_id,sob_form_id_2 NULL NULL NULL 365990 Using where
如何优化此查询? sob_field_value
是text
字段
我拉字段中每个具有不同值的这些形式。
SELECT
sob_datas.id,
sob_datas.sob_field_name,
sob_datas.sob_field_value
FROM sob_datas
WHERE sob_form_id = '.$proof['SobForm']['id'].' AND
EXISTS(
SELECT
sub_sob_datas.id
FROM sob_datas AS sub_sob_datas
WHERE sub_sob_datas.sob_form_id = '.$original['SobForm']['id'].' AND
sub_sob_datas.sob_field_name = sob_datas.sob_field_name AND
sub_sob_datas.sob_field_value != sob_datas.sob_field_value
)
我还要指出,我打算只更新变化的领域使用新值
哈哈,对...很好....谈论过于复杂化在我的末端 – Webnet 2011-04-19 19:58:47