select m. *, d. * from view_ordertracking m, which m and d are extremely complex view, m table data volume of high efficiency and less d table data volume efficiency is low, but because it is left the join, the driver table is d, therefore the entire SQL is slow,
Left the join view_majorplanprocess d
On m.o rderno=d.o rderno
And m.o rderLineNum=d.o rderlineno
Therefore, I try to inner join, found soon, so want to continue along this road continue to optimize, changed the inner join + union, found that results in, don't know why (m, d are no duplicate data), after improvement of SQL
select m. *, d. * from view_ordertracking m
Left the join view_majorplanprocess d
On m.o rderno=d.o rderno
And m.o rderLineNum=d.o rderlineno
Union all
The select m. *, a lot of null from view_ordertracking m
Why two SQL data in, left the join is not inner join + left table data?
CodePudding user response:
After changing inner join inequitable;Suggested that the view, instead of materialized views;
CodePudding user response: