UnKnown Query generated in Backhand...

  • Hi All,

    We have a Cube that will be refreshed daily, and lately its been taking more than an hour for refreshing and as a result Cube refresh process has been failing in many occasions. My Colleague ran the Activity Monitor on the base database and found the below mentioned query running many times. He forwarded it to me asking its purpose.

    "

    SET NOCOUNT ON;

    DECLARE @previous_collection_time datetime;

    DECLARE @previous_request_count bigint;

    DECLARE @current_collection_time datetime;

    DECLARE @current_request_count bigint;

    DECLARE @batch_requests_per_sec bigint;

    DECLARE @interval_sec bigint;

    -- Get the previous snapshot's time and batch request count

    SELECT TOP 1 @previous_collection_time = collection_time, @previous_request_count = request_count

    FROM #am_request_count

    ORDER BY collection_time DESC;

    -- Get the current total time and batch request count

    SET @current_collection_time = GETDATE();

    SELECT @current_request_count = cntr_value

    FROM sys.sysperfinfo

    WHERE counter_name = 'Batch Requests/sec' COLLATE Latin1_General_BIN;

    SET @interval_sec =

    -- Avoid divide-by-zero

    CASE

    WHEN DATEDIFF (second, @previous_collection_time, @current_collection_time) = 0 THEN 1

    ELSE DATEDIFF (second, @previous_collection_time, @current_collection_time)

    END;

    -- Calc the Batch Requests/sec rate for the just-completed time interval.

    SET @batch_requests_per_sec = (@current_request_count - @previous_request_count) / @interval_sec;

    -- Save off current batch count

    INSERT INTO #am_request_count (collection_time, request_count)

    VALUES (@current_collection_time, @current_request_count);

    -- Return the batch requests/sec rate for the just-completed time interval.

    SELECT ISNULL (@batch_requests_per_sec, 0) AS batch_requests_per_sec;

    -- Get rid of all but the most recent snapshot's data

    DELETE FROM #am_request_count WHERE collection_time < @current_collection_time;

    "

    After some research on this i came to the conclusion that the query is being generated by the system for event logging.

    Can someone please tell me why the above query was generated and what is it used for?

    Thanks in advance.

  • Duplicate thread. Please direct replies here. http://www.sqlservercentral.com/Forums/Topic1538311-391-1.aspx

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply