postgresqlgoogle-cloud-platformgoogle-cloud-sqlpg-repack

Invoking pg_repack extension in gcp cloud sql


We have installed the pg_repack extension in Cloud SQL by following the guide:

https://cloud.google.com/sql/docs/postgres/extensions#pg_repack

The installation of the extension works fine and it shows up in the list of extensions when running \dx.

We then want to invoke the extension, but it is unclear from where this should be done. The docs just say to "run the command":

pg_repack -h <hostname> -d testdb -U csuper1 -k -t t1

We cant find anywhere in our project where this command can be invoked though. Do we have to set up a compute engine instance for this, or is there some other way?

We only use Cloud Run for running our code at the moment and would like to keep things as small/simple as possible.


Solution

  • Our solution: We built a docker image that wrapped pg_repack with http, and then deployed it as a Cloud Run service. This enabled us to invoke pg_repack periodically using the cloud scheduler.