您加入的字段是索引数据类型和类似数据类型吗?
此外,查看您的查询,您似乎正在基于几个表之间的 OR 进行连接,我怀疑这可能会阻止 MySQL 有效地使用索引。
尝试使用显式连接,这会使连接更加明显,并为其发布 EXPLAIN:-
SELECT a.d_id,
a.d_n,
a.t_id,
a.act,
a.pm,
b.d_t,
b.d_d,
b.pm,
b.mec_of_act,
b.d_g,
b.d_c,
c.n_id,
c.s_name,
c.s_status,
c.s_p,
c.dis
FROM d_tar a
INNER JOIN d_char b ON a.d_id=b.d_id
INNER JOIN d_b f ON a.d_id=f.d_id
INNER JOIN d_s e ON a.d_id=e.d_id
INNER JOIN c_int d ON d.in_name IN (b.d_n, e.snym, f.b_name)
INNER JOIN ct c ON d.n_id=c.n_id
WHERE a.t_id='847'
编辑 - 如果不同列名上的连接阻止使用有用的索引,那么以下可能会起作用(尽管这假设 c_int.n_id 是唯一的): -
SELECT a.d_id,
a.d_n,
a.t_id,
a.act,
a.pm,
b.d_t,
b.d_d,
b.pm,
b.mec_of_act,
b.d_g,
b.d_c,
CASE WHEN c1.n_id IS NOT NULL THEN c1.n_id WHEN c2.n_id IS NOT NULL THEN c2.n_id WHEN c3.n_id IS NOT NULL THEN c3.n_id END AS n_id,
CASE WHEN c1.n_id IS NOT NULL THEN c1.s_name WHEN c2.n_id IS NOT NULL THEN c2.s_name WHEN c3.n_id IS NOT NULL THEN c3.s_name END AS s_name,
CASE WHEN c1.n_id IS NOT NULL THEN c1.s_status WHEN c2.n_id IS NOT NULL THEN c2.s_status WHEN c3.n_id IS NOT NULL THEN c3.s_status END AS s_status,
CASE WHEN c1.n_id IS NOT NULL THEN c1.s_p WHEN c2.n_id IS NOT NULL THEN c2.s_p WHEN c3.n_id IS NOT NULL THEN c3.s_p END AS s_p,
CASE WHEN c1.n_id IS NOT NULL THEN c1.dis WHEN c2.n_id IS NOT NULL THEN c2.dis WHEN c3.n_id IS NOT NULL THEN c3.dis END AS dis
FROM d_tar a
INNER JOIN d_char b ON a.d_id = b.d_id
INNER JOIN d_b f ON a.d_id = f.d_id
INNER JOIN d_s e ON a.d_id = e.d_id
LEFT JOIN c_int d1 ON d1.in_name = b.d_n
LEFT JOIN c_int d2 ON d2.in_name = e.snym
LEFT JOIN c_int d3 ON d3.in_name = f.b_name
LEFT JOIN ct c1 ON d1.n_id = c1.n_id
LEFT JOIN ct c2 ON d1.n_id = c2.n_id
LEFT JOIN ct c3 ON d1.n_id = c3.n_id
WHERE a.t_id='847'
AND (c1.n_id IS NOT NULL
OR c2.n_id IS NOT NULL
OR c2.n_id IS NOT NULL)