内存数据库

发布于 2024-07-15 11:03:10 字数 249 浏览 9 评论 0原文

我正在使用 SqlServer 来驱动 WPF 应用程序,我当前正在使用 NHibernate 并预读取所有数据,以便出于性能原因对其进行缓存。 这适用于单个客户端应用程序,但我想知道是否有一个可以使用的内存数据库,以便我可以在同一台计算机上的多个应用程序之间共享信息。 理想情况下,这将位于我的 NHibernate 堆栈下方,因此我的代码不必更改。 实际上,我希望将我的数据库从服务器上的传统格式移动为客户端上的内存数据库。

注意我只需要选择功能。

I'm using SqlServer to drive a WPF application, I'm currently using NHibernate and pre-read all the data so it's cached for performance reasons. That works for a single client app, but I was wondering if there's an in memory database that I could use so I can share the information across multiple apps on the same machine. Ideally this would sit below my NHibernate stack, so my code wouldn't have to change. Effectively I'm looking to move my DB from it's traditional format on the server to be an in memory DB on the client.

Note I only need select functionality.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

菊凝晚露 2024-07-22 11:03:10

如果您甚至需要将所有信息加载到内存中,我会感到非常惊讶。 我这样说是因为,作为一个例子,我目前正在开发一个 Web 应用程序,该应用程序(由于各种原因)在许多页面上加载数千条记录。 这就是PHP+MySQL。 即便如此,它也能在 100 毫秒内完成并渲染页面。

在你走这条路之前,请确保你必须这样做。 首先使您的数据库尽可能高性能。 现在显然这包括拥有适当的索引和调整数据库之类的事情,但即使是本末倒置。

首先,您需要确保拥有一个良好的关系数据模型:适合高性能查询的模型。 这既是艺术,也是科学。

另外,您可能喜欢 NHibernate,但ORM 并不总是最佳选择。 有一些极端情况,例如,手工编码的 SQL 会非常优越。

现在假设您有一个良好的数据模型,并假设您已经优化了索引和数据库参数,然后您已经正确配置了 NHibernate,那么只有这样,当且仅当性能仍然是一个问题时,您才应该考虑将数据存储在内存中。

从长远来看,我唯一需要这样做的时候是在每天需要执行数百万笔交易的系统上。

避免内存缓存的原因之一是它增加了很多复杂性。 您必须处理缓存过期、对底层数据存储的独立更新、是否使用同步或异步更新、如何为客户端提供一致(如果不是最新)的数据视图、如何处理等问题具有故障转移和复制等功能。 需要付出巨大的复杂性成本。

假设您已完成上述所有操作并且仍然需要它,那么在我看来您需要的是缓存或网格解决方案。 这是Java 网格/集群解决方案概述,但其中许多(例如 Coherence、memcached)也适用于 .Net。 .Net 的另一个选择是 Velocity

需要指出并强调的是,像 NHibernate 这样的东西只有在没有任何外部更新数据库的情况下才是一致的,并且只有一个支持 NHibernate 的进程(除非是集群解决方案)。 如果两台不同 PC 上的两个桌面应用程序都使用 NHibernate 更新同一个数据库,则缓存根本无法工作,因为持久性单元根本不知道对方所做的更改。

I would be incredibly surprised if you even need to load all your information in memory. I say this because, just as one example, I'm working on a Web app at the moment that (for various reasons) loads thousands of records on many pages. This is PHP + MySQL. And even so it can do it and render a page in well under 100ms.

Before you go down this route make sure that you have to. First make your database as performant as possible. Now obviously this includes things like having appropriate indexes and tuning your database but even though are putting the horse before the cart.

First and foremost you need to make sure you have a good relational data model: one that lends itself to performant queries. This is as much art as it is science.

Also, you may like NHibernate but ORMs are not always the best choice. There are some corner cases, for example, that hand-coded SQL will be vastly superior in.

Now assuming you have a good data model and assuming you've then optimized your indexes and database parameters and then you've properly configured NHibernate, then and only then should you consider storing data in memory if and only if performance is still an issue.

To put this in perspective, the only times I've needed to do this are on systems that need to perform millions of transactions per day.

One reason to avoid in-memory caching is because it adds a lot of complexity. You have to deal with issues like cache expiry, independent updates to the underlying data store, whether you use synchronous or asynchronous updates, how you give the client a consistent (if not up-to-date) view of your data, how you deal with failover and replication and so on. There is a huge complexity cost to be paid.

Assuming you've done all the above and you still need it, it sounds to me like what you need is a cache or grid solution. Here is an overview of Java grid/cluster solutions but many of them (eg Coherence, memcached) apply to .Net as well. Another choice for .Net is Velocity.

It needs to be pointed out and stressed that something like NHibernate is only consistent so long as nothing externally updates the database and that there is exactly one NHibernate-enabled process (barring clustered solutions). If two desktop apps on two different PCs are both updating the same database with NHibernate the caching simply won't work because the persistence units simply won't be aware of the changes the other is making.

少女情怀诗 2024-07-22 11:03:10

http://www.db4o.com/ 可以成为您的朋友!

http://www.db4o.com/ can be your friend!

2024-07-22 11:03:10

Velocity 是一个由 Microsoft 设计的进程外对象缓存服务器,它几乎可以完成您想要的任务,尽管它只是目前为CTP形式。

我相信memcached也有包装器,它也可以用来缓存对象。

Velocity is an out of process object caching server designed by Microsoft to do pretty much what you want although it's only in CTP form at the moment.

I believe there are also wrappers for memcached, which can also be used to cache objects.

贪恋 2024-07-22 11:03:10

您可以使用 HANA Express 版本。 您可以免费下载,它位于内存中,柱状并允许进一步的分析功能,例如文本分析、地理空间或预测。 您还可以使用 ODBC、JDBC、node.js hdb 库、REST API 等进行访问。

You can use HANA, express edition. You can download it for free, it's in-memory, columnar and allows for further analytics capabilities such as text analytics, geospatial or predictive. You can also access with ODBC, JDBC, node.js hdb library, REST APIs among others.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文