Re: pg_cron for vacuum - dynamic table set

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: saket bansal <saket(dot)tcs(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_cron for vacuum - dynamic table set
Date: 2022-02-03 21:48:26
Message-ID: CAKFQuwact+u_Er3pBVYPUO7Vg0aV7tuhLOQErpzO8kwXvs83Yw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 3, 2022 at 2:29 PM saket bansal <saket(dot)tcs(at)gmail(dot)com> 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 "\" .
>

Right, because you don't get to use psql meta-commands if you are not using
psql.

>
> 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?
>

Have a pg_cron job that dynamically creates other pg_cron jobs that only
run once?

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Munro 2022-02-03 21:50:48 Re: sort order for UTF-8 char column with Japanese UTF-8
Previous Message Adrian Klaver 2022-02-03 21:40:30 Re: pg_cron for vacuum - dynamic table set