Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJycW-0003Tf-44 for pgsql-sql@arkaria.postgresql.org; Thu, 13 Jul 2023 15:52:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qJycU-0002bN-Cr for pgsql-sql@arkaria.postgresql.org; Thu, 13 Jul 2023 15:52:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJycU-0002bE-4J for pgsql-sql@lists.postgresql.org; Thu, 13 Jul 2023 15:52:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qJycN-000Fxn-BA for pgsql-sql@lists.postgresql.org; Thu, 13 Jul 2023 15:52:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 36DFqW8W2884750; Thu, 13 Jul 2023 11:52:32 -0400 From: Tom Lane To: "David G. Johnston" cc: Shaozhong SHI , pgsql-sql Subject: Re: Can we set time exception? In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Thu, 13 Jul 2023 08:36:48 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2884748.1689263552.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 13 Jul 2023 11:52:32 -0400 Message-ID: <2884749.1689263552@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Thu, Jul 13, 2023 at 7:46 AM Shaozhong SHI > wrote: >> Can we set a time exception? >> If the function responds with result in a given time, we take the result. >> If the response of the function exceeds the time set, skip it. > No. Function execution happens on a single thread (i.e., synchronous) in a > stacked manner. There is no way for the caller to get processing control > back other than the callee returning. You could do something with statement_timeout, but the recovery would have to be managed on the client (application) side. IIRC we measure that as the total time to finish a client query, not the time of any one statement within a function or DO block. regards, tom lane