通过多个可扩展的工作过程在PostgreSQL中查看行的最佳方法

发布于 2025-01-17 17:10:28 字数 587 浏览 2 评论 0原文

我有一张很大的桌子,上面有100,000的行,带钥匙和一个时间戳。

我目前使用了使用NodeJS和PG查询最古老的Last_updipdipdemestamp,执行函数,然后使用NOW()更新行,然后更新行。

我的问题是,我试图通过更多的流程找到一种方式,并优化了我的行结帐。我从每个过程开始一次选择1000个过程,每个过程都有1000个倍数的偏移,进行操作,然后更新

我开始阅读有关Select使用for Update和Skip Lock的信息,但是似乎这可能会产生一些性能影响吗?还找不到清晰的方法来在同一查询中进行选择/更新,还是我一次与此帖子相似,但我是否继续进行单个更新,但似乎这可能对这样的大型操作不利?

在Postgres In in of Postgres in in of Postgres 上实现更新

是否有人接触过此类设置?我还一直在辩论我是否需要构建自己的中间件来管理一个工作项目,然后工人使用该表来选择/删除?

I have a very large table with 100,000's of rows with a key and a timestamp.

I currently use batch of AWS servers that are using NodeJS and PG to query for the oldest last_updated timestamp, perform the function, and then update the row with the NOW().

My issue is I am trying to find a way scale with more processes and optimize my row checkouts. I started with each process selecting 1000 at a time and each one having a multiple of 1000 for OFFSET, doing the operation, and then updating

I started to read about SELECT using FOR UPDATE and SKIP LOCK but seems like this could have some performance impacts? Also can't find a clear way to do the SELECT/UPDATE in the same query or do I keep doing single updates at a time similar to this post but seems like this may not be good for larger operations like this?

implementing an UPDATE on SELECT in Postgres

Has anyone approached this type of setup? I also have been debating do I need to build my own middleware that manages a pool of work items and then the workers use that table to select/delete?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文