并开始通过AJAX监视长时间运行的SQL查询进度 [英] Begin and monitor progress on long running SQL queries via ajax

查看:129
本文介绍了并开始通过AJAX监视长时间运行的SQL查询进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能开始一个查询,将采取显著的时间,并通过Ajax监控从UI进展如何?

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

我认为在启动过程的计划立即运行运行一次作业。我可以将结果存储在一个临时表中,以便快速检索一旦完成。我也可以登录该报告的运行时间和平均说了出来,以guestimate的运行时间进度条。

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.

我使用Microsoft SQL 2005的时刻,但我愿意和其他DBMS,例如SQL Server 2008,MySQL等,如果有必要的。

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

推荐答案

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

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

您有第二个数据库连接监视多少行,加工出来的源行,并显示一个简单的x行处理每隔几秒钟

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)

如果你有一个源表太:

SELECT COUNT(*) FROM SourceTable WITH (NOLOCK)

..然后你可以使用加工y行X

..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...

这篇关于并开始通过AJAX监视长时间运行的SQL查询进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆