Skip to main content
cherdt
Inspiring
Dec 20, 2012 4:57 PM UTC
Answered

timeout attribute of cfquery ignored?

I set up the following SELECT * test on a table with a huge number of rows, just to make sure the query would run over 1 second:

<cfquery name="test" datasource="#ds#" timeout="1">

          SELECT *

          FROM request_stats

</cfquery>

The debugging info indicates that the query took 2539ms, but instead of throwing an error the query ran & returned results. Maybe I am not understanding how the timeout attribute should work? The CF docs indicate that "Because the timeout attribute only affects the maximum time for each suboperation of a query, the cumulative time may exceed its value" -- but does a simple query like this one have suboperations?

I'm using CF9.

This topic is closed to new replies. Start a new post to keep the conversation going.
cherdt
cherdtCorrect answer
Inspiring
Jan 3, 2013 9:13 PM UTC

Good catch, that is what I was wondering, if the actual query doesn't take a second I wouldn't expect it to time out. Displaying the results could take longer than one second if it is a lot of data.

Tim


It turned out that in both my test case and the actual case I was trying to solve, the queries were not exceeding the 1 second threshhold.

It ended up being the database login time that was excessive, not the actual query time. In the CF administrator I set the Login Timout to 1 second (under the Advanced Settings). After I applied that, the query would throw a database error when the login time exceeded 1 second. (The login time does not, apaprently, factor into the cfquery timeout.)

Thanks to Tim and Dan for the help!

10 replies

cherdt
cherdtAuthor
Inspiring
Jan 2, 2013 3:35 PM UTC

According to Charlie Arehart on New for CF9 (and 9.0.1): a query timeout that really works, with a caveat, the timeout attribute of the cfquery tag "generally does not work."

As mentioned in the same post, there is a query timeout option available in the CF Administrator for certain data source types, but unfortunately not for the ODBC Socket that I'm using.

Additionally, the CF9 docs indicate, regarding the timeout attribute, that "For JDBC statements, ColdFusion sets this attribute. For other drivers, see the driver documentation." So it's possible that the timeout attribute does work, but only for some drivers.

Translate
Inspiring
Jan 2, 2013 5:16 PM UTC

I just ran queries with 1 second timeouts against redbrick, oracle, and sql server databases and in all three cases I got error messages saying the query had timed out.

Don't ignore Tim Cunningham's reply.  It was well thought out.

Translate
cherdt
cherdtAuthor
Inspiring
Jan 2, 2013 6:09 PM UTC

Thanks for running those tests, it's good to know that it should work as expected.

(I wasn't ignoring Tim--he posted his question as I was adding an unrelated comment.)

Translate
Tim Cunningham
Participating Frequently
Jan 2, 2013 3:10 PM UTC

If you run the query directly on the SQL machine, how long does it take? Less than one second?

Translate
cherdt
cherdtAuthor
Inspiring
Jan 2, 2013 5:30 PM UTC

Good question. Unfortunately, I don't have access to the machine.

Translate
Tim Cunningham
Participating Frequently
Jan 2, 2013 5:31 PM UTC

Also what type of datasource did you set up in the CFAdministrator?

Translate