有没有一种方法可以缓存视图,以便对其进行快速查询? [英] Is there a way to cache a View so that queries against it are quick?

查看:66
本文介绍了有没有一种方法可以缓存视图,以便对其进行快速查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Views非常陌生,所以如果这是一个愚蠢的问题,请原谅我,但是我有一个View确实有助于优化一个非常笨拙的查询,并允许我针对其中的一小部分列进行选择但是,我希望View实际上可以存储在某个位置,以便选择它不会花费很长时间.

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的执行速度以及对我的View的查询持续时间)我感觉到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查询的艰苦工作,然后*使我随后对这个静态View的选择真正迅速.

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.

这篇关于有没有一种方法可以缓存视图,以便对其进行快速查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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