如何在 php 中停止 sql 查询执行? [英] How can I stop sql query execution in php?
问题描述
我有一个很长的 SQL 查询执行.当我关闭浏览器页面时,sql 查询 (postgresql) 继续执行.如何在页面关闭时停止执行?
I have a long SQL query execution. When I close the browser page, sql query (postgresql) execution continues. How can I stop it executing on page closing?
推荐答案
好吧,如果没有 JavaScript,您无法保证断开连接,而确保您知道窗口已关闭的唯一真正方法就是拥有它不断地 ping 服务器——有时页面关闭事件不会触发.所以你基本上需要在后台跟踪 ping 的东西,如果在给定的时间内没有触发,调用终止进程.
Well, you can't guarantee that there is a disconnect without JavaScript and the only real way to ensure that you know that the window has closed is to have it continually ping the server -- sometimes the page closing events don't fire. So you'd basically need something in the background tracking the pings and if one does not fire in a given time, call the kill process.
据我所知,如果不以管理员身份登录并实际强制关闭威胁,就不可能告诉 PostgreSQL 连接.该方法称为 pg_cancel_backend.我不会用命令行kill强制终止进程.这可能会产生影响,而使用内置工具可以避免这些影响.
As far as I know, it is not possible to tell a PostgreSQL connection without signing in as an admin and actually forcing the threat to close. The method is called pg_cancel_backend. I WOULD NOT forcibly terminate the process with the command line kill. That could have repercussions which can be avoided by using built in tools.
这篇关于如何在 php 中停止 sql 查询执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!