CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_c` AS select C,c1 from A union all select C,C2 from B
A、B为物理表且字段C都有索引
select *from view_c where C=xxx
使用这个语句时速度非常慢
select C,c1 from A where C=xxx
union all
select C,C2 from B where C=xxx
看一下速度如何。
另外贴出
show index from A;
show index from B;
explain select *from view_c where C=xxx;
以供分析。