问题描述
我对视图非常陌生,所以如果这是一个愚蠢的问题,请原谅我,但我有一个视图,它对优化非常笨拙的查询非常有帮助,并允许我选择列中的一小部分子集但是,我希望视图实际上存储在某个地方,以便选择它不会花费很长时间.
I'm extremely new to Views so please forgive me if this is a silly question, but I have a View that is really helpful in optimizing a pretty unwieldy query, and allows me to select against a small subset of columns in the View, however, I was hoping that the View would actually be stored somewhere so that selecting against it wouldn't take very long.
我可能弄错了,但我感觉到(从 create view
执行的速度和我对视图的查询的持续时间)视图实际上是作为查询运行的到外部查询,每次我选择反对它.
I may be mistaken, but I get the sense (from the speed with which create view
executes and from the duration of my queries against my View) that the View is actually run as a query prior to the external query, every time I select against it.
我真的希望我能忽略一些机制,当我运行 CREATE VIEW 时,它可以完成查询 View 查询的艰苦工作*then,这样我随后针对这个静态视图的选择就会非常迅速.
I'm really hoping that I'm overlooking some mechanism whereby when I run CREATE VIEW it can do the hard work of querying the View query *then, so that my subsequent select against this static View would be really swift.
顺便说一句,我完全理解,显然这个 VIEW 将是创建 VIEW 时存在的数据的快照,并且不会反映在创建 VIEW 之后插入/更新的任何新信息.这实际上正是我所需要的.
BTW, I totally understand that obviously this VIEW would be a snapshot of the data that existed at the time the VIEW was created and wouldn't reflect any new info that was inserted/updated subsequent to the VIEW's creation. That's actually EXACTLY what I need.
TIA
推荐答案
你想做的是具体化你的观点.看看 http://www.fromdual.com/mysql-materialized-views.
What you want to do is materialize your view. Have a look at http://www.fromdual.com/mysql-materialized-views.
这篇关于有没有办法缓存视图,以便快速查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!