Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id EF4A42E003B for ; Mon, 18 Feb 2008 23:03:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 82755-05 for ; Mon, 18 Feb 2008 23:03:30 -0400 (AST) Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by postgresql.org (Postfix) with ESMTP id 9304E2E0039 for ; Mon, 18 Feb 2008 23:03:38 -0400 (AST) Received: from 219-89-100-120.jetstart.xtra.co.nz ([219.89.100.120] helo=[192.168.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JRIlX-00063n-FT; Tue, 19 Feb 2008 16:03:31 +1300 Message-ID: <47BA470A.8000904@opencloud.com> Date: Tue, 19 Feb 2008 16:03:38 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Tom Lane CC: Gregory Stark , PostgreSQL - JDBC Subject: Re: Implementing setQueryTimeout() References: <47B8E200.2020307@opencloud.com> <5350.1203299903@sss.pgh.pa.us> <47B8EB1C.8090802@opencloud.com> <87ejbao6bg.fsf@oxford.xeocode.com> <47BA2A6E.6050907@opencloud.com> <17814.1203384054@sss.pgh.pa.us> In-Reply-To: <17814.1203384054@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/133 X-Sequence-Number: 18340 Tom Lane wrote: > Oliver Jowett writes: >> I'd argue that "close connection on network timeout if setQueryTimeout() >> is set" is better than "do absolutely nothing special if >> setQueryTimeout() is set", anyway. If you don't want queries being >> aborted because they are taking too long to complete.. don't set a query >> timeout! > > I think it's a serious, serious conceptual error to tie network timeouts > to query timeouts. Why? I don't understand this argument. setQueryTimeout() is documented as: > Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds. If the limit is exceeded, an SQLException is thrown. That would seem to cover any sort of delay, not just "it is a slow query on the server side". If the Statement can't execute in N seconds, return an error. That could mean slow network - slow query - whatever. I don't see why clients that want timeouts care about the cause of the slowness - all they care about is that they get control back within some reasonable amount of time, surely? What's the use case where you would use setQueryTimeout() but don't actually mean "give me control back in N seconds"? If a client is postgresql-aware, it could always set statement_timeout itself if it really does mean "don't take more than N seconds of server time" instead of "please return within N seconds". -O