PostgreSQL 中的数据库间通信

发布于 2024-08-21 17:01:14 字数 488 浏览 2 评论 0原文

我正在使用 PostgreSQL 8.4。我真的很喜欢新的 unnest() 和 array_agg() 功能;他们是时候认识到数组的动态处理潜力了!

不管怎样,我正在研究经常使用长数组的网络服务器后端。它们将是两个连续的进程,每个进程都发生在不同的物理机器上。每个这样的进程都是一个轻量级的Python应用程序,它“管理”每台机器上数据库的SQL查询以及来自前端的请求。

第一个进程将生成一个数组,该数组将被缓冲到 SQL 表中。每个这样生成的数组都可以通过主键访问。完成后,第一个 python 应用程序将密钥发送到第二个 python 应用程序。然后,在另一台机器上运行的第二个 python 应用程序使用它来获取在第一台机器中找到的引用数组。然后它将其发送到它自己的数据库以生成最终结果。

我发送密钥的原因是因为我希望这将使两个过程进行得更快。但我真正想要的是一种让第二个数据库向第一个数据库发送查询的方法,以期最大限度地减少序列化延迟等。

任何帮助/建议将不胜感激。

谢谢

I am using PostgreSQL 8.4. I really like the new unnest() and array_agg() features; it is about time they realize the dynamic processing potential of their Arrays!

Anyway, I am working on web server back ends that uses long Arrays a lot. Their will be two successive processes which will each occur on a different physical machine. Each such process is a light python application which ''manage'' SQL queries to the database on each of their machines as well as requests from the front ends.

The first process will generate an Array which will be buffered into an SQL Table. Each such generated Array is accessible via a Primary Key. When its done the first python app sends the key to the second python app. Then the second python app, which is running on a different machine, uses it to go get the referenced Array found in the first machine. It then sends it to it's own db for generating a final result.

The reason why I send a key is because I am hopping that this will make the two processes go faster. But really what I would like is for a way to have the second database send a query to the first database in the hope of minimizing serialization delay and such.

Any help/advice would be appreciated.

Thanks

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

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

发布评论

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

评论(3

笑叹一世浮沉 2024-08-28 17:01:14

听起来你想要 dblink 来自 contrib 。这允许一些数据库间的 postgres 通信。 pg 文档很棒,应该提供所需的示例。

Sounds like you want dblink from contrib. This allows some inter-db postgres communication. The pg docs are great and should provide the needed examples.

几味少女 2024-08-28 17:01:14

不确定我完全理解,但你看过“通知/监听”吗? http://www.postgresql.org/docs/8.1/static/ sql-listen.html

not sure I totally understand, but you've looked at notify/listen? http://www.postgresql.org/docs/8.1/static/sql-listen.html

冰葑 2024-08-28 17:01:14

我正在考虑侦听/通知或带有缓存(例如内存缓存)的东西。您可以将密钥发送到内存缓存,并让第二个 python 应用程序从那里检索它。您甚至可以通过监听/通知来做到这一点...例如;发送密钥并通知您的第二个应用程序该密钥位于内存缓存中等待检索。

I am thinking either listen/notify or something with a cache such as memcache. You would send the key to memcache and have the second python app retrieve it from there. You could even do it with listen/notify... e.g; send the key and notify your second app that the key is in memcache waiting to be retrieved.

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