pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: pg_cron for vacuum - dynamic table set
Date: Thu, 3 Feb 2022 15:55:29 -0600
Message-ID: <db019bac-b18a-e2fb-6c95-7750bb3e6d21@gmail.com> (raw)
In-Reply-To: <CACkcRNiuyVkDJBEQg+u6sG=CA5-b73Jx1bzCVZO_dvacNfKMag@mail.gmail.com>
References: <CACkcRNiuyVkDJBEQg+u6sG=CA5-b73Jx1bzCVZO_dvacNfKMag@mail.gmail.com>

On 2/3/22 3: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 "\"| .
> 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?

What about running the command from regular cron?

-- 
Angular momentum makes the world go 'round.

view thread (5+ messages)

Message-ID: <db019bac-b18a-e2fb-6c95-7750bb3e6d21@gmail.com>
Permalink:  ../db019bac-b18a-e2fb-6c95-7750bb3e6d21@gmail.com/
Also on:    postgresql.org/message-id/db019bac-b18a-e2fb-6c95-7750bb3e6d21@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: pg_cron for vacuum - dynamic table set
  In-Reply-To: <db019bac-b18a-e2fb-6c95-7750bb3e6d21@gmail.com>
  References: <CACkcRNiuyVkDJBEQg+u6sG=CA5-b73Jx1bzCVZO_dvacNfKMag@mail.gmail.com> <db019bac-b18a-e2fb-6c95-7750bb3e6d21@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox