From 0fba6c00253d61de42e67451429c9e26ce380148 Mon Sep 17 00:00:00 2001 From: piano35-edb <160748516+piano35-edb@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:16:16 -0600 Subject: [PATCH 1/4] extensions-docs-327-pgcron initial --- .../pg_extensions/pg_cron/configuring.mdx | 34 +++++++++ advocacy_docs/pg_extensions/pg_cron/index.mdx | 23 ++++++ .../pg_extensions/pg_cron/installing.mdx | 71 +++++++++++++++++++ .../pg_extensions/pg_cron/rel_notes/index.mdx | 10 +++ .../rel_notes/pg_cron_1.6.4_rel_notes.mdx | 6 ++ advocacy_docs/pg_extensions/pg_cron/using.mdx | 20 ++++++ 6 files changed, 164 insertions(+) create mode 100644 advocacy_docs/pg_extensions/pg_cron/configuring.mdx create mode 100644 advocacy_docs/pg_extensions/pg_cron/index.mdx create mode 100644 advocacy_docs/pg_extensions/pg_cron/installing.mdx create mode 100644 advocacy_docs/pg_extensions/pg_cron/rel_notes/index.mdx create mode 100644 advocacy_docs/pg_extensions/pg_cron/rel_notes/pg_cron_1.6.4_rel_notes.mdx create mode 100644 advocacy_docs/pg_extensions/pg_cron/using.mdx diff --git a/advocacy_docs/pg_extensions/pg_cron/configuring.mdx b/advocacy_docs/pg_extensions/pg_cron/configuring.mdx new file mode 100644 index 00000000000..7a8ccce9a45 --- /dev/null +++ b/advocacy_docs/pg_extensions/pg_cron/configuring.mdx @@ -0,0 +1,34 @@ +--- +title: Configuring pg_cron +navTitle: Configuring +--- + +1. In `postgresql.conf`, add `pg_cron` to the `shared_preload_libraries` parameter: + + ```ini + shared_preload_libraries = 'pg_cron' + ``` + + !!! Note + If `shared_preload_libraries` has other extensions, then you can add `pg_cron` to the list. The order doesn't matter. + !!! + +1. Metadata tables for `pg_cron` will be created in the "postgres" database, but you can alter this with: +```ini +cron.database_name = 'mydbname' +``` +1. You can alter the timezone of pg_cron from GMT if required: +```ini +cron.timezone = 'PRC' +``` +1. Restart Postgres. + +1. Create the `pg_cron` extension in your database: + + ```shell + CREATE EXTENSION pg_cron; + ``` +1. Grant usage to `pg_cron` as needed to allow other users to schedule and manage their own jobs: +```ini +GRANT USAGE ON SCHEMA cron TO username; +``` \ No newline at end of file diff --git a/advocacy_docs/pg_extensions/pg_cron/index.mdx b/advocacy_docs/pg_extensions/pg_cron/index.mdx new file mode 100644 index 00000000000..bf41efe4e4f --- /dev/null +++ b/advocacy_docs/pg_extensions/pg_cron/index.mdx @@ -0,0 +1,23 @@ +--- +title: 'pg_cron' +indexCards: none +navigation: + - rel_notes + - installing + - configuring + - using +directoryDefaults: + product: pg_cron +--- + +`pg_cron` is an extension released as open source software under the PostgreSQL License. + +`pg_cron` is a cron-based job scheduler for PostgreSQL. You can schedule PostgreSQL commands directly from the database using a cron-based syntax. + +For more information about `pg_cron`, see: + +- [Installing pg_cron](installing.mdx) +- [Configuring pg_cron](configuring.mdx) +- [Using pg_cron](using.mdx) + + diff --git a/advocacy_docs/pg_extensions/pg_cron/installing.mdx b/advocacy_docs/pg_extensions/pg_cron/installing.mdx new file mode 100644 index 00000000000..c0246850376 --- /dev/null +++ b/advocacy_docs/pg_extensions/pg_cron/installing.mdx @@ -0,0 +1,71 @@ +--- +title: Installing pg_cron +navTitle: Installing +--- + +`pg_cron` is supported on the same platforms as the Postgres distribution you're using. Support for `pg_cron` starts with Postgres 10. For details, see: + +- [EDB Postgres Advanced Server Product Compatibility](https://www.enterprisedb.com/platform-compatibility#epas) +- [PostgreSQL Product Compatibility](https://www.enterprisedb.com/resources/platform-compatibility#pg) +- [EDB Postgres Extended Server Product Compatibility](https://www.enterprisedb.com/resources/platform-compatibility#epas_extended) + +## Installation + +Before you begin the installation process: + +- Install Postgres. See: + + - [Installing EDB Postgres Advanced Server](/epas/latest/installing/) + + - [Installing PostgreSQL](https://www.postgresql.org/download/) + + - [Installing EDB Postgres Extended Server](/pge/latest/installing/) + +- Set up the repository. + + Setting up the repository is a one-time task. If you've already set up your repository, you don't need to perform this step. + + To set up the repository, go to [EDB repositories](https://www.enterprisedb.com/repos-downloads) and follow the instructions provided there. + +## Install the package + +The syntax for the package install command is: + +```shell +# For SLES, CentOS, RHEL and its derivatives +sudo -y install edb--pg-cron1 + +# For Debian and Ubuntu +sudo -y install edb--pg-cron-1 +``` + +Where: +- ``is the package manager used with your operating system: + + | Package manager | Operating system | + | --------------- | -------------------------------- | + | dnf | RHEL 8/9 and derivatives | + | yum | RHEL 7 and derivatives, CentOS 7 | + | zypper | SLES | + | apt-get | Debian and derivatives | + +- `` is the distribution of Postgres you're using: + + | Postgres distribution | Value | + | ---------------------------- | ---------- | + | PostgreSQL | pg | + | EDB Postgres Advanced Server | as | + | EDB Postgres Extended Server | postgresextended | + +- `` is the version of Postgres you're using. + +For example, to install pg_cron for EDB Postgres Advanced Server 15 on a RHEL 8 platform: + +```shell +sudo dnf -y install edb-as15-pg-cron1 +``` + + + + + diff --git a/advocacy_docs/pg_extensions/pg_cron/rel_notes/index.mdx b/advocacy_docs/pg_extensions/pg_cron/rel_notes/index.mdx new file mode 100644 index 00000000000..ee92eb29320 --- /dev/null +++ b/advocacy_docs/pg_extensions/pg_cron/rel_notes/index.mdx @@ -0,0 +1,10 @@ +--- +title: 'pg_cron release notes' +navTitle: "Release notes" +indexCards: none +--- +The pg_cron documentation describes the latest version of pg_cron, including minor releases and patches. These release notes cover what was new in each release. For new functionality introduced in a minor or patch release, there are also indicators in the content about the release that introduced the feature. + +| Version | Release Date | +| ----------------------------------- | ------------ | +| [1.6.4](pg_cron_1.6.4_rel_notes) | 09 Aug 2024 | diff --git a/advocacy_docs/pg_extensions/pg_cron/rel_notes/pg_cron_1.6.4_rel_notes.mdx b/advocacy_docs/pg_extensions/pg_cron/rel_notes/pg_cron_1.6.4_rel_notes.mdx new file mode 100644 index 00000000000..cd60466bea6 --- /dev/null +++ b/advocacy_docs/pg_extensions/pg_cron/rel_notes/pg_cron_1.6.4_rel_notes.mdx @@ -0,0 +1,6 @@ +--- +title: Release notes for pg_cron version 1.6.4 +navTitle: "Version 1.6.4" +--- + +For `pg_cron` release notes, see the [pg_cron official release notes](https://github.com/citusdata/pg_cron/releases/). diff --git a/advocacy_docs/pg_extensions/pg_cron/using.mdx b/advocacy_docs/pg_extensions/pg_cron/using.mdx new file mode 100644 index 00000000000..137b6d497e5 --- /dev/null +++ b/advocacy_docs/pg_extensions/pg_cron/using.mdx @@ -0,0 +1,20 @@ +--- +title: Using pg_cron +navTitle: Using +--- + +Use `pg_cron` to remove unused space from a table and optionally sort tuples according to a particular index. + +# Viewing the job status +```shell +select * from cron.job_run_details order by start_time desc limit 10; +``` + +# Purging the `cron.job_run_details` table +```shell +SELECT cron.schedule('0 0 * * *', $$DELETE + FROM cron.job_run_details + WHERE end_time < now() - interval '14 days'$$); +``` + +For more information on using `pg_cron`, see the [pg_cron documentation](https://github.com/citusdata/pg_cron). \ No newline at end of file From 72ca74a6b507274b121f2514ec4478363d9c6128 Mon Sep 17 00:00:00 2001 From: piano35-edb <160748516+piano35-edb@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:29:17 -0600 Subject: [PATCH 2/4] update extensionrefs json url for pg_cron --- advocacy_docs/pg_extensions/extensionrefs.json | 2 +- advocacy_docs/pg_extensions/index.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/advocacy_docs/pg_extensions/extensionrefs.json b/advocacy_docs/pg_extensions/extensionrefs.json index 02032016927..fe9f5665eeb 100644 --- a/advocacy_docs/pg_extensions/extensionrefs.json +++ b/advocacy_docs/pg_extensions/extensionrefs.json @@ -118,7 +118,7 @@ "mongo_fdw": "https://github.com/Percona-Lab/mongodb_fdw", "mysql_fdw": "https://github.com/EnterpriseDB/mysql_fdw", "bdr_5.x":"https://www.enterprisedb.com/docs/pgd/latest/", - "pg_cron":"https://github.com/citusdata/pg_cron", + "pg_cron":"https://www.enterprisedb.com/docs/pg_extensions/pg_cron/", "sql_profiler":"https://www.enterprisedb.com/docs/pem/latest/profiling_workloads/using_sql_profiler/", "pg_squeeze":"https://www.enterprisedb.com/docs/pg_extensions/pg_squeeze/", "wal2json":"https://www.enterprisedb.com/docs/pg_extensions/wal2json/", diff --git a/advocacy_docs/pg_extensions/index.mdx b/advocacy_docs/pg_extensions/index.mdx index 51282a95a48..c1dc26e3787 100644 --- a/advocacy_docs/pg_extensions/index.mdx +++ b/advocacy_docs/pg_extensions/index.mdx @@ -92,7 +92,7 @@ Categories of extensions: PostgreSQL Non-Contrib Extensions/Modules ip4r––––––– orafce––––––– -pg_cron–– +pg_cron–– pg_failover_slots pg_permissions––––––– pg_squeeze–– From 7d0c2b9a57657eacf78e4e0b796d5116462b6b77 Mon Sep 17 00:00:00 2001 From: piano35-edb <160748516+piano35-edb@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:43:31 -0600 Subject: [PATCH 3/4] edits --- advocacy_docs/pg_extensions/pg_cron/configuring.mdx | 9 ++++++--- advocacy_docs/pg_extensions/pg_cron/using.mdx | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/advocacy_docs/pg_extensions/pg_cron/configuring.mdx b/advocacy_docs/pg_extensions/pg_cron/configuring.mdx index 7a8ccce9a45..15da3876dae 100644 --- a/advocacy_docs/pg_extensions/pg_cron/configuring.mdx +++ b/advocacy_docs/pg_extensions/pg_cron/configuring.mdx @@ -8,26 +8,29 @@ navTitle: Configuring ```ini shared_preload_libraries = 'pg_cron' ``` - - !!! Note + If `shared_preload_libraries` has other extensions, then you can add `pg_cron` to the list. The order doesn't matter. - !!! + 1. Metadata tables for `pg_cron` will be created in the "postgres" database, but you can alter this with: ```ini cron.database_name = 'mydbname' ``` + 1. You can alter the timezone of pg_cron from GMT if required: ```ini cron.timezone = 'PRC' ``` + 1. Restart Postgres. + 1. Create the `pg_cron` extension in your database: ```shell CREATE EXTENSION pg_cron; ``` + 1. Grant usage to `pg_cron` as needed to allow other users to schedule and manage their own jobs: ```ini GRANT USAGE ON SCHEMA cron TO username; diff --git a/advocacy_docs/pg_extensions/pg_cron/using.mdx b/advocacy_docs/pg_extensions/pg_cron/using.mdx index 137b6d497e5..6709108edb6 100644 --- a/advocacy_docs/pg_extensions/pg_cron/using.mdx +++ b/advocacy_docs/pg_extensions/pg_cron/using.mdx @@ -5,16 +5,18 @@ navTitle: Using Use `pg_cron` to remove unused space from a table and optionally sort tuples according to a particular index. -# Viewing the job status +## Viewing the job status ```shell select * from cron.job_run_details order by start_time desc limit 10; ``` -# Purging the `cron.job_run_details` table + +## Purging the `cron.job_run_details` table ```shell SELECT cron.schedule('0 0 * * *', $$DELETE FROM cron.job_run_details WHERE end_time < now() - interval '14 days'$$); ``` + For more information on using `pg_cron`, see the [pg_cron documentation](https://github.com/citusdata/pg_cron). \ No newline at end of file From 9946fd430f8bdef370d964cea42a9b693a0298e0 Mon Sep 17 00:00:00 2001 From: piano35-edb <160748516+piano35-edb@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:45:43 -0600 Subject: [PATCH 4/4] edits --- advocacy_docs/pg_extensions/pg_cron/using.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advocacy_docs/pg_extensions/pg_cron/using.mdx b/advocacy_docs/pg_extensions/pg_cron/using.mdx index 6709108edb6..6dcbf3eca8f 100644 --- a/advocacy_docs/pg_extensions/pg_cron/using.mdx +++ b/advocacy_docs/pg_extensions/pg_cron/using.mdx @@ -3,7 +3,7 @@ title: Using pg_cron navTitle: Using --- -Use `pg_cron` to remove unused space from a table and optionally sort tuples according to a particular index. +Use `pg_cron` to schedule various database maintenance and management tasks. ## Viewing the job status ```shell