通过 ajax 开始并监控长时间运行的 SQL 查询的进度

发布于 2024-08-02 17:49:40 字数 210 浏览 4 评论 0原文

是否可以启动一个需要大量时间的查询并通过 Ajax 从 UI 监视进度?

我考虑将该过程作为“运行一次”作业启动,计划立即运行。我可以将结果存储在临时表中,以便在完成后快速检索。我还可以记录报告的运行时间并求出平均值,以估计进度条的运行时间。

我目前使用 Microsoft SQL 2005,但如果有必要,我愿意使用其他 DBMS,例如 SQL 2008、MySQL 等。

Is it possible to start a query that will take a significant amount of time and monitor progress from the UI via Ajax?

I considered starting the process as a "run once" job that is scheduled to run immediately. I could store the results in a temporary table for quick retrieval once it's complete. I could also log the run time of the report and average that out, to guestimate the running time for the progress bar.

I use Microsoft SQL 2005 at the moment, but I'm willing to other DBMS such as SQL 2008, MySQL, etc if necessary.

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

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

发布评论

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

评论(1

﹏半生如梦愿梦如真 2024-08-09 17:49:40

一个想法是,如果长时间运行的作业填充另一个表。

您有第二个数据库连接来监视源行中处理了多少行,并每隔几秒显示一个简单的“已处理 x 行”

SELECT COUNT(*) FROM TargetTable WITH (NOLOCK)

如果您也有一个源表:

SELECT COUNT(*) FROM SourceTable WITH (NOLOCK)

..那么您可以使用“x of y rows”基本上

,您必须使用第二个连接来监视第一个连接。然而,你还需要一些东西来衡量......

One idea, if the long running job populates another table.

You have a 2nd database connection to monitor how many rows are processed out of the source rows, and show a simple "x rows processed" every few second

SELECT COUNT(*) FROM TargetTable WITH (NOLOCK)

If you have a source table too:

SELECT COUNT(*) FROM SourceTable WITH (NOLOCK)

..then you can use "x of y rows processed"

Basically, you have to use a 2nd connection to monitor the first. However, you also need something to measure...

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