Set timeout for specific queries?

  • Hi,

    is it possible to set a specific timeout for a query?

    Example:

    SET TIMEOUT_FOR_THE_FOLLOWING_QUERY = 10 sec

    SELECT * FROM TABLENAME

    If the query execution time is more then 10 sec, the SQL-Server should stop the execution and returns an error-result.

    If the query was executed in less than 10 sec, the SQL Server should bring back the result.

    Or are there some workarounds?

    Greetings,

    dev-fridge

  • I'm not sure if the resource governor can help at a granular level like this, but it would be worth looking into.

    Other than that, no I don't think you can set this within the TSQL statement. You can however set it in the connection string on the client application.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (1/15/2009)


    I'm not sure if the resource governor can help at a granular level like this, but it would be worth looking into.

    Other than that, no I don't think you can set this within the TSQL statement. You can however set it in the connection string on the client application.

    Resource Governor can only limit CPU and RAM usage for a workload group, you cannot use it to cancel queries after a certain time.

    The only way to set a query timeout is through the client application.

    [font="Verdana"]Markus Bohse[/font]

  • MarkusB (1/16/2009)


    Resource Governor can only limit CPU and RAM usage for a workload group, you cannot use it to cancel queries after a certain time.

    The only way to set a query timeout is through the client application.

    Thanks. That's what I thought. I haven't read up on the resource governor at all, but it's on the list.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

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