MySQL视图-何时使用&什么时候不去

问题描述:

mysql认证指南建议视图可用于:

the mysql certification guide suggests that views can be used for:

  • 创建可能涉及计算的摘要
  • 使用WHERE子句选择一组行,隐藏不相关的信息
  • 加入或合并的结果
  • 允许通过视图对基表进行更改,以保留原始表的架构以容纳其他应用程序

但来自如何实现搜索2个不同的表格数据?

也许你是对的,那不是 工作,因为MySQL的意见不好 与索引的朋友.但是还是.是 有什么要寻找的 商店桌子?

And maybe you're right that it doesn't work since mysql views are not good friends with indexing. But still. Is there anything to search for in the shops table?

我了解到视图不能很好地与索引配合使用,因此,它可能会带来很多便利,从而对性能造成很大的影响吗?

i learn that views dont work well with indexing so, will it be a big performance hit, for the convenience it may provide?

This mysql-forum-thread about indexing views gives a lot of insight into what mysql views actually are.

一些要点:

  • 视图实际上只不过是存储的选择语句
  • 视图的数据是该视图引用的表的数据.
  • 从当前版本开始,无法在视图上创建索引
  • 如果使用合并算法,则将使用基础表的索引.
  • 底层索引不可见.视图上的DESCRIBE将不显示索引列.