简体   繁体   English

存储/重用sql查询结果的最佳方法

[英]Best way to store / reuse the results of sql queries

I had a request to come up with a way to store and reuse results of SQL queries, and I'm seriously in need of suggestions. 我要求提出一种存储和重用SQL查询结果的方法,因此我非常需要建议。
The situation in detail: 情况详细:
They want to use a scheduler to execute long running queries, then store the results in a way that these can later be used to create tables, charts and reports. 他们希望使用调度程序来执行长时间运行的查询,然后以某种方式存储结果,以便以后可用于创建表,图表和报表。 The reports need to be able to filter the result set further (based on user input) so making the scheduler do the reports is out of the question. 报告需要能够进一步过滤结果集(基于用户输入),因此使调度程序执行报告是不可能的。 The results need to be stored in some sort of a uniform way: we don't know the exact number of long running queries, there might be hundreds of them. 结果需要以某种统一的方式存储:我们不知道长时间运行的查询的确切数量,可能有数百个。 I've considered making database tables which describe and store result sets but don't really like the idea of "tables that store tables" (and the thought that it might not turn out strongly typed). 我曾考虑过制作用于描述和存储结果集的数据库表,但实际上并不喜欢“存储表的表”的想法(并且认为它可能不会成为强类型的)。 I've also thought about serialising those results into files. 我还考虑过将这些结果序列化为文件。 I don't know how long we want to hold on to these query results, which would be important of course. 我不知道我们要保留这些查询结果多长时间,这当然很重要。 We're using .net 4.0 and firebird technologies. 我们正在使用.net 4.0和firebird技术。 If I'm not posting this question to the right place, please give me some directions. 如果我没有将此问题发布到正确的位置,请给我一些指导。

We're looking at doing some very similar things. 我们正在做一些非常相似的东西。 For our implementation we're looking to store the result sets as a 对于我们的实现,我们正在寻找存储结果集作为一个

List<T> 

of a some Object, so if it were books, we'd have a book class. 一些对象的,所以如果它的书,我们就会有一个书类。 The RunQuery function would return in that case 在这种情况下,RunQuery函数将返回

List<Book> RunQuery(MyQuery query);

For the actual storage of the sets, a Memcache server seems to be a good simple choice for our needs. 对于集合的实际存储,Memcache服务器似乎是满足我们需求的简单好选择。 There are a number of memcache clients freely available that are really easy to use. 有一些免费提供的是很容易使用的memcache客户端。 You'll need to make your objects binary serializable but that's pretty easy - check out protobuf for .net 您需要使您的对象二进制可序列化,但这很容易-签出.net的protobuf

We can use web api endpoints called from Angular or jQuery to "Query" or filter the result sets that are retrieved from the Memcache server. 我们可以使用Web API端点从角或jQuery来“查询”叫或筛选从内存缓存服务器检索的结果集。 We usually structure our GetData style methods to automatically look to the cache first, and then to hit the database. 我们通常会构造GetData样式方法,以首先自动查找缓存,然后查找数据库。 You could probably do something similar, perhaps work some notification into them mix - ie We'll run the query and ping you when its finished. 你也许可以做类似的事情,也许是工作的一些通知到他们组合 - 即我们将运行查询和ping你,当它完成。

Hope this helps 希望这可以帮助

Scott 史考特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM