Re: pg_cron for vacuum - dynamic table set

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: saket bansal <saket(dot)tcs(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_cron for vacuum - dynamic table set
Date: 2022-02-03 21:40:30
Message-ID: f8bf725d-e46a-dd53-04f4-f0e146e0b162@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-02-03 21:48:26 Re: pg_cron for vacuum - dynamic table set
Previous Message saket bansal 2022-02-03 21:29:05 pg_cron for vacuum - dynamic table set