How to show Progress-bar in Status bar when the SQL Query retrieve data from SQL Server? - sql

I have a VB.NET Application.
In the same have some query, which result will display in a DataGridView.
It need 2 to 3 min to execute my query.
Now I want to show a Progressbar on Status bar that will display the Data Retrieve progress . After Complete, it will hide from Statusbar and a Label will show "Completed".
If any expert help me I will be thankful to him.

You question covers a lot of ground. The first thing that comes to my mind is, why do you have a query that takes so long to run, and can it be optimized? How bit is the data set you are returning? 10 rows, 100s rows, 100000s? If the dataset is large, are you using pagination? ADO.Net does provide an async interface model, see here Async SQLCommand. One possibility is to issue your query async then show your progress bar, and close the progress bar when you get a completed notification.
Another option is to start the query in another thread, but that is probably not needed if you can use the async SQLCommand. However, if you want to show a progress bar that updates to show %complete, as opposed to a "waiting" indicator, that will be challenging. For one thing, you have no clue as to how long the query will take. It is not a deterministic process such as reading a file from disk, where you can estimate file size, transfer speed, etc. I do not think there is any mechanism in SQL server to query, "how's my query going?" A poor and wasteful alternative would be to first run one query to get the count of records you expect, then divide the fetching query into smaller subqueries with some range parameter and execute in "chunks". Again, that is not efficient. Maybe someone knows of alternatives.

Related

qtsql-querymodel-editablesqlmodel: why need refresh?

I study for example http://doc.qt.io/Qt-5/qtsql-querymodel-editablesqlmodel-cpp.html
I have one question, why after query UPDATE statement, model is cleared on view (view is empty) and shows data after refresh calling SELECT statement?
I think so, there's no SELECT running and model doesn't have to change.
The model is directly displaying the result of a SELECT query, so it displayed the state of the database at the time of querying.
The code that updates the database uses operations that do not directly affect the model's internal data (the cached result of the previous SELECT query), so there is no change as far as the view is concerned.
Applying the SELECT query again in refresh() updates the model's knowledge about that database state and thus results in new data being available in the view.
The "clearing" is caused by the call to clear() in setData().
Not sure why it is there, I don't think it is necessary.

SSRS - Report doesn't loads via Report Builder, while it does via SQL

this is my first question here.
I struggled days and days trying to find a solution everywhere with no success.
Basically I have a standard stored procedure pulling out a report dataset in a few seconds (5-6 seconds).
It aggregates (GROUPING BY and SUMMING) 23000 rows.
Indeed, my final dataset comes out with 4 rows and 33 columns executing, as said, in 5-6 seconds.
Unfortunately, while trying to load it via ReportBuilder, it loads endlessly (querying SQL Server, the StoredProcedure remains stuck in a RUNNING status forever).
Everything on ReportBuilder (DB Accesses, Dataset, Parameters, Matrix....) is right configured: I was indeed able to load it until I added a few additional (4) fields.
The SQL dataset is basically something like:
PARAMETERS DECLARATION
SELECT
FIELDS
FROM
(SELECT
FIELD A
SUMS
FROM
TABLE
JOIN TABLES
WHERE
PARAMETERS MATCHING
GROUP BY A
) AS B
ORDER BY FIELD
An "external layer" SELECT was needed to make some calculations on some FIELDS, also in some cases using some PARAMETERS.
That's it.
I use to work with huge datasets, sometimes pulling out 30,000 rows with 110 fields, but if something loads via SQL it also does always via ReportBuilder: this is the very first time it behaves in this different way.
So I'm asking if there are some strange SSRS/ReportBuilder limitations I never faced in my experience.
Any help would be really really appreciated!
Thanks in advance to everyone who'll spend time :)

Why does SSRS taking too long to execute in design and more while building it?

I have two data-sets in my SSRS tool, first table contain 12,000 records and second one 26,000 records. And 40 columns in each table.
While building a report each time I go preview - it takes forever to display.
Is any way to do something to avoid that, so I can at least not spent so much time to build this report?
Thank you in advance.
Add a dummy parameter to limit your dataset. Or just change your select to select top 100 while building the report
#vercelli's answer is a good one. In addition you can change your cache options in the designer (for all resultsets including patramters) so that the queries are not rerun each time.
This is really useful plus - a couple of tips for you:
1. I don't recommend caching until you are happy with the your dataset results.
2. If you are using the cache and you want to do a quick refresh then the data is stored in a ".data" file in the same location as a your .rdl. You can delete this to query the database again if required.

Determining query's progress (Oracle PL/SQL)

I am a developer on a web app that uses an Oracle database. However, often the UI will trigger database operations that take a while to process. As a result, the client would like a progress bar when these situations occur.
I recently discovered that I can query V$SESSION_LONGOPS from a second connection, and this is great, but it only works on operations that take longer than 6 seconds. This means that I can't update the progress bar in the UI until 6 seconds has passed.
I've done research on wait times in V$SESSION but as far as I've seen, that doesn't include the waiting for the query.
Is there a way to get the progress of the currently running query of a session? Or should I just hide the progress bar until 6 seconds has passed?
Are these operations Pl/SQL calls or just long-running SQL?
With PL/SQL operations we can write messages with SET_SESSION_LONGOPS() in the DBMS_APPLICATION_INFO package. We can monitor these messages in V$SESSION_LONGOPS. Find out more.
For this to work you need to be able to quantify the operation in units of work. These must be iterations of something concrete, and numeric not time. So if the operation is insert 10000 rows you could split that up into 10 batches. The totalwork parameter is the number of batches (i.e. 10) and you call SET_SESSION_LONGOPS() after every 1000 rows to increment the sofar parameter. This will allow you to render a thermometer of ten blocks.
These messages are session-based but there's no automatic way of distinguishing the current message from previous messages from the same session & SID. However if you assign a UID to the context parameter you can then use that value to filter the view.
This won't work for a single long running query, because there's no way for us to divide it into chunks.
i found this very usefull
dbms_session.set_module("MY Program" , "Kicking off ... ")
..
dbms_session.set_action("Extracting data ... ")
..
dbms_session.set_action("Transforming data ... ")
..
you can monitor the progress using
select module , action from v$session where sid = :yoursessionid
I've done quite a lot of web development with Oracle over the years and found that most users prefer an indeterminate progress bar, than a determinate bar that is inaccurate (a la pretty much any of Microsoft's progress bars which annoy me no end), and unfortunately there is no infallible way of accurately determining query progress.
Whilst your research into the long ops capability is admirable and would definitely help to make the progress of the database query more reliable, it can't take into account the myriad of other variables that may/will affect the web operation's transactional progress (network load, database load, application server load, client-side data parsing, the user clicking on a submit button 1,000 times, etc and so on).
I'd stick to the indeterminate progress method using Javascript callbacks. It's much easier to implement and it will manage your user's expectations as appropriate.
Using V$_SESSION_LONGOPS requires to set TIMED_STATISTICS=true or SQL_TRACE=true. Your database schema must be granted the ALTER SESSION system privilege to do so.
I once tried using V$_SESSION_LONGOPS with a complex and long running query. But it turned up that V$_SESSION_LONGOPS may show the progress of parts of the query like full table scans, join operations, and the like.
See also: http://www.dba-oracle.com/t_v_dollar_session_longops.htm
What you can do is just to show the user "the query is still running". I implemented a <DIV> nested into a <TD> that gets longer with every status request sent by the browser. Status requests are initiated by window.SetTimeout (every 3 seconds) and are AJAX calls to a server-side procedure. The status report returned by the server-side procedure simply says "we are still running". The progress bar's width (i.e. the <DIV>'s width) increments by 5% of the <TD>s width every time and is reset to 5% after showing 100%.
For long running queries you might track the time they took in a separate table, possibly with individual entries for varying where clauses. You could use this to display the average time plus the time that just elapsed in the client-side dialog.
If you have a long running PL/SQL procedure or the like on the server side doing several steps, try this:
create a table for status messages
use a unique key for any process the user starts. Suggestion: client side's javascript date in milliseconds + session ID.
in case the long running procedure is to be started by a link in a browser window, create a job using DBMS_JOB.SUBMIT to run the procedure instead of running the procedure directly
write a short procedure that updates the status table, using PRAGMA AUTONOMOUS_TRANSACTION. This pragma allows you to commit updates to the status table without committing your main procedure's updates. Each major step of your main procedure should have an entry of its own in this status table.
write a procedure to query the status table to be called by the browser
write a procedure that is called by an AJAX call if the use clicks "Cancel" or closes the window
write a procedure that is called by the main procedure after completion of each step: it queries the status table and raises an exception with an number in the 20,000s if the cancel flag was set or the browser did not query the status for, say, 60 seconds. In the main procedure's exception handler look for this error, do a rollback, and update the status table.

logic:equal slow the performance for showing 10000 records

I am having 10000 records
in jsp page 32 columns
29 colums i am using and it is slowing the process any other way
Whether slows down because it is checking for every row.
user dont want pagination he needs to show all 10000 not 1000 records
I have a datalist which iterate , within the iterate loop i gave the logic:equal condition
..................................
for changing the bgcolor only i am using the logic:notequal
Any Idea
Does he can read or print them all. What's a wasting of server/client resource and bandwidth!
But in helpless case, you can you javascript to change color to redistribute server processing. Or use good load strategy, for example: not all at once but delay loading (use ajax I assume), load part in view first,..