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 1nFjqO-0004i4-Ps for pgsql-general@arkaria.postgresql.org; Thu, 03 Feb 2022 21:40:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nFjqM-00084l-B0 for pgsql-general@arkaria.postgresql.org; Thu, 03 Feb 2022 21:40:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFjqK-00084c-F3 for pgsql-general@lists.postgresql.org; Thu, 03 Feb 2022 21:40:42 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFjqE-00015a-UN for pgsql-general@lists.postgresql.org; Thu, 03 Feb 2022 21:40:39 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id DC46032022B0; Thu, 3 Feb 2022 16:40:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 03 Feb 2022 16:40:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; bh=ckIE/ZX2YS+9qV xD0A+bNpg/scHUOwCWgviiP44q/UY=; b=GhvroBYEvxBoon1II6dqLmG4T/PJJT A+DW+DwT1jC0NuCfSdVIx8n2K/opZt9zlemsyDprp5U1FPT9oki4M8Xs8NIJZu9H gpRg4PBIcA/aEiUa/S8arQhvxA7PYnS+xHVwGZuIIDbi71EdCzpo81EXx0+bN+fR cyRnDfADNLk6jPUEmMD4/yMeh0hf27vpn9efsyDwDCe34gn+iQzEVPznEJxykdk9 EeM0QVY731udN7OWz5/gebGi+l2b9f9MmNnkaeg91xbi8Tv2v+JXPas7kbEFaZd2 hlMDrBT+zEaNJPG/Qey54WxUHmGHTeh5ReO2PcVdkzGuvV4B0A1kYkwQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=ckIE/ZX2YS+9qVxD0A+bNpg/scHUOwCWgviiP44q/UY=; b=P2xZaR97 d+GxHCbrS5iH+cEhJSfi0t0J1mrjyPbO+Dyvt4jA3LmIzVrQiF3lNvSKeXS9IOlc 6BdxnT2LHjkwSDElKfJnPMTJyEB/a7Y0SaH2jdJBgcZPshKirqEQekJfVwPlCPN3 qIhmT0tq+hKLRQxa/5RRicHw4OVkVjhOF44S94Onkf8CNu+BvLe3CJVlzK+SEN9s qrJkU2eibUz+aPtSkCNyUSVEyuLhygoK5QvvTX+9i60J6ff+mi6gSfgVDAHx1mDY iQ8lk4QIgLQepNJuMO1OUecOxX6mSI31DHzvbVsiyH0pxc08FigdKeytQ/0/tauz ieMqb7YLbR64qA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrgeejgdduheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeevveefveefueegffekkefhgeeiueffgfetueejvdfg hfeujeejhfekjeelgedtgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Feb 2022 16:40:31 -0500 (EST) Subject: Re: pg_cron for vacuum - dynamic table set To: saket bansal , PostgreSQL General References: From: Adrian Klaver Message-ID: Date: Thu, 3 Feb 2022 13:40:30 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/3/22 1:29 PM, saket bansal wrote: > Hi, I am trying to schedule pg_cron to generate a set of commands and > then run them. E.g |select 'vacuum freeze '||table_name from > inventory_for_vacuum \gexec| . This works well at command line, but when > scheduled in pg_cron, it fails with syntax error |ERROR: syntax error at > or near "\"| . \gexec is a psql metacommand and will only run in that client. I'm guessing that is not the case in the pg_cron task? > Since vacuum doesn't work inside a transaction block |ERROR: VACUUM > cannot run inside a transaction block|, I cannot use a function directly > to run over a loop. > Any guidance to make it work or an alternative? > > -- Adrian Klaver adrian.klaver@aklaver.com