MySql 查看性能 [英] MySql views performance

查看:27
本文介绍了MySql 查看性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您要走上使用视图的道路,您如何确保良好的性能?

If you are going down the road of using views, how can you ensure good performance?

或者最好不要一开始就使用视图,而是将等效的内容合并到您的选择语句中?

Or is it better not to use views in the first place and just incorporate the equivalent into your select statements?

推荐答案

视情况而定.

这完全取决于您通过视图查看的内容.但很可能会减少您的努力并提供更高的性能.当 SQL 语句引用非索引视图时,解析器和查询优化器会分析 SQL 语句和视图的来源,然后将它们解析为单个执行计划.SQL 语句没有一个计划,视图没有一个单独的计划.

It Depends.

It totally depends on what you are viewing through view. But most probably reducing your effort and giving higher performance. When SQL statement references a nonindexed view, the parser and query optimizer analyze the source of both the SQL statement and the view and then resolve them into a single execution plan. There is not one plan for the SQL statement and a separate plan for the view.

未编译视图.它是由其他表组成的虚拟表.当您创建它时,它不会驻留在您的服务器上的某处.构成视图的底层查询受到与查询优化器相同的性能提升或影响的影响.我从未测试过视图 VS 其底层查询的性能,但我认为性能可能会略有不同.如果数据相对静态,您可以在索引视图上获得更好的性能.这可能是您在编译"方面的想法.

A view is not compiled. Its a virtual table made up of other tables. When you create it, it doesn't reside somewhere on your server. The underlying queries that make up the view are subject to the same performance gains or dings of the query optimizer. I've never tested performance on a view VS its underlying query, but i would imagine the performance may vary slightly. You can get better performance on an indexed view if the data is relatively static. This may be what you are thinking maybe in terms of "compiled".

  1. 查看数据而不将数据存储到对象中.
  2. 限制表格的视图,即可以隐藏表格中的某些列.
  3. 连接两个或多个表并将其作为一个对象显示给用户.
  4. 限制对表的访问,使任何人都不能将行插入表中.

查看这些有用的链接:

  1. VIEW 与 SQL 语句的性能
  2. 视图是否比简单查询更快?
  3. Mysql VIEWS 与 PHP 查询
  4. MySql 视图是否动态且高效?
  5. 物化视图与表格:有什么优势?
  6. 查询视图比执行 SQL 慢直接?
  7. ATEMPTABLE 视图性能问题的解决方法
  8. 通过在 SQL Server 中使用索引视图查看性能提升

这篇关于MySql 查看性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆