Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 374BE14518EA for ; Thu, 8 Dec 2011 22:28:10 -0400 (AST) Received: from mail-yx0-f174.google.com ([209.85.213.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RYqC0-0000he-Kg for pgsql-sql@postgresql.org; Fri, 09 Dec 2011 02:28:10 +0000 Received: by yenm11 with SMTP id m11so1687353yen.19 for ; Thu, 08 Dec 2011 18:27:55 -0800 (PST) Received: by 10.236.139.199 with SMTP id c47mr8483638yhj.113.1323397675474; Thu, 08 Dec 2011 18:27:55 -0800 (PST) Received: from ayaki.localdomain (124-169-254-28.dyn.iinet.net.au. [124.169.254.28]) by mx.google.com with ESMTPS id u20sm19804291ank.9.2011.12.08.18.27.52 (version=SSLv3 cipher=OTHER); Thu, 08 Dec 2011 18:27:54 -0800 (PST) Message-ID: <4EE17226.40206@ringerc.id.au> Date: Fri, 09 Dec 2011 10:27:50 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: "feng.zhou" CC: pgsql-sql Subject: Re: Query Timeout Question References: <201112090944451236494@wellintech.com> In-Reply-To: <201112090944451236494@wellintech.com> Content-Type: multipart/alternative; boundary="------------090109000704090103060500" X-Pg-Spam-Score: -0.8 (/) X-Archive-Number: 201112/34 X-Sequence-Number: 36095 This is a multi-part message in MIME format. --------------090109000704090103060500 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 12/09/2011 09:44 AM, feng.zhou wrote: > Hi > I set query timeout in code by using SQLSetStmtAttr ODBC API . > SQLSetStmtAttr( StatementHandle, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)timeout, 0 ) > ; > SQLExecute(StatementHandle); > But I find this setting has no effect.Before adding timeout setting, > SQLExecute costs 47 seconds.After adding timeout, costing time is same. First: You're using a very old patch release with known bugs. Update to 8.4.10 . As for the timeout: PostgreSQL doesn't support query timeouts. It supports a session-level statement timeout. I don't know whether the ODBC driver uses that or not. Examine the ODBC `mylog' output after enabling psqlODBC debugging, and examine the server log after turning on query logging, so you can see what the ODBC driver actually asks the server for when you set a query timeout. -- Craig Ringer --------------090109000704090103060500 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 12/09/2011 09:44 AM, feng.zhou wrote:
Hi
I set query timeout in code by using SQLSetStmtAttr ODBC API .
 
SQLSetStmtAttr( StatementHandle, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)timeout, 0 ) ;
SQLExecute(StatementHandle);
 
But I find this setting has no effect.Before adding timeout setting, SQLExecute costs 47 seconds.After adding timeout, costing time is same.

First: You're using a very old patch release with known bugs. Update to 8.4.10 .

As for the timeout: PostgreSQL doesn't support query timeouts. It supports a session-level statement timeout. I don't know whether the ODBC driver uses that or not. Examine the ODBC `mylog' output after enabling psqlODBC debugging, and examine the server log after turning on query logging, so you can see what the ODBC driver actually asks the server for when you set a query timeout.

--
Craig Ringer
--------------090109000704090103060500--