Is there a way to cache a View so that queries against it are quick?(有没有办法缓存视图,以便快速查询?)
问题描述
我对视图非常陌生,所以如果这是一个愚蠢的问题,请原谅我,但我有一个视图,它对优化非常笨拙的查询非常有帮助,并允许我选择列中的一小部分子集但是,我希望视图实际上存储在某个地方,以便选择它不会花费很长时间.
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.
这篇关于有没有办法缓存视图,以便快速查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有办法缓存视图,以便快速查询?
基础教程推荐
- 从字符串 TSQL 中获取数字 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
