有没有办法缓存视图,以便快速查询?

2024-04-15数据库问题
2

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

问题描述

我对视图非常陌生,所以如果这是一个愚蠢的问题,请原谅我,但我有一个视图,它对优化非常笨拙的查询非常有帮助,并允许我选择列中的一小部分子集但是,我希望视图实际上存储在某个地方,以便选择它不会花费很长时间.

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.

这篇关于有没有办法缓存视图,以便快速查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

MySQL GROUP BY DateTime +/- 3 秒
MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)...
2024-04-16 数据库问题
14