我想知道 mysql 视图如何针对 where 子句进行优化。我创建了一个 mysql 视图。
CREATE VIEW `testView` AS
select ID from `table1`
union
select ID from `table2`
当我触发这个查询时
select * from testView where some_col = 'some_val'
触发此查询后mysql会做什么。
mysql 是否从内存中的 table1 和 table2 中获取所有行,然后触发 where 子句?
或者
直接在内部触发此查询?
select ID from `table1` where some_col = 'some_val'
union
select ID from `table2` where some_col = 'some_val'