取消在Ruby on Rails的电流/活动查询

编程入门 行业动态 更新时间:2024-10-25 00:24:38
本文介绍了取消在Ruby on Rails的电流/活动查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的项目,我运行一个庞大的查询返回大量的数据。由于这个查询的大小,运行时有时会超过1分钟。忽略了其他问题,这可能会产生,有没有什么办法来取消当前正在运行的查询?

In my project I am running a massive query returning lots of data. Due to the size of this query, the runtime sometimes exceeds 1 minute. Ignoring other issues this may create, is there any way to cancel a currently running query?

例如,用户开始查询并重定向到一个标准的正在载入结果...页面。如果他们再决定他们不再想要的结果,他们可以单击取消按钮,会以某种方式终止正在运行的查询。

For example, the user starts the query and is redirected to a standard 'Loading Results...' page. If they then decide that they no longer want the results, they can click a 'Cancel' button which will somehow terminate the running query.

这是可能的,以及如何能不能做到?

Is this possible and how can it be done?

谢谢!

推荐答案

尝试使用 pg_cancel_backend 。

从文档:

取消一个后端的当前查询。你可以对另一个后端有完全一样调用函数的用户相同的角色执行此。在其他情况下,你必须是一个超级用户。

Cancel a backend's current query. You can execute this against another backend that has exactly the same role as the user calling the function. In all other cases, you must be a superuser.

更多推荐

取消在Ruby on Rails的电流/活动查询

本文发布于:2023-10-27 16:05:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533871.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:电流   Ruby   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!