如果您要走上使用视图的道路,您如何确保良好的性能?
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 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".
这篇关于MySql 查看性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!