postgresqlextensions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
postgresqlextensions [2021/09/26 16:00] – z0hpvk | postgresqlextensions [2025/03/08 22:24] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== PostgreSQL Extensions ===== | ===== PostgreSQL Extensions ===== | ||
- | ==== PG_CRON | + | ==== pg_cron |
[[https:// | [[https:// | ||
Line 22: | Line 22: | ||
<code SQL> | <code SQL> | ||
SELECT cron.schedule(' | SELECT cron.schedule(' | ||
+ | SELECT cron.schedule_in_database(' | ||
SELECT cron.unschedule(< | SELECT cron.unschedule(< | ||
- | SELECT | + | |
- | SELECT | + | SELECT |
+ | |||
+ | SELECT | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | JOIN cron.job j on j.jobid = jrd.jobid | ||
+ | ORDER BY start_time; | ||
</ | </ | ||
- | ==== PGLOGICAL | + | ==== pglogical |
[[https:// | [[https:// | ||
Line 35: | Line 44: | ||
</ | </ | ||
- | ==== PGBOUNCER | + | ==== pgbouncer |
- | [[https:// | + | [[https:// |
< | < | ||
psql -p 6432 -U pgbouncer pgbouncer | psql -p 6432 -U pgbouncer pgbouncer | ||
SHOW STATS; | SHOW STATS; | ||
+ | SHOW STATS_TOTALS; | ||
+ | SHOW STATS_AVERAGES; | ||
SHOW CONFIG; | SHOW CONFIG; | ||
SHOW DATABASES; | SHOW DATABASES; | ||
</ | </ | ||
- | ==== PG_STAT_STATEMENTS | + | Any changes to the pgbouncer.ini file can be updated via ... |
+ | < | ||
+ | RELOAD; | ||
+ | </ | ||
+ | ==== pg_stat_statements | ||
[[https:// | [[https:// | ||
Line 56: | Line 71: | ||
</ | </ | ||
- | ==== POSTGIS | + | ==== postgis |
[[https:// | [[https:// | ||
< | < | ||
sudo apt install --no-install-recommends postgresql-13-postgis-3{, | sudo apt install --no-install-recommends postgresql-13-postgis-3{, | ||
+ | </ | ||
+ | < | ||
+ | SELECT postgis_full_version(); | ||
</ | </ | ||
- | ==== POSTGRES_FDW | + | ==== postgres_fdw |
[[https:// | [[https:// | ||
- | ==== PG_BUFFERCACHE | + | ==== pg_buffercache |
[[https:// | [[https:// | ||
+ | < | ||
+ | \c < | ||
+ | CREATE EXTENSION PG_BUFFERCACHE; | ||
+ | </ | ||
<code SQL> | <code SQL> | ||
SELECT n.nspname, c.relname, | SELECT n.nspname, c.relname, | ||
Line 82: | Line 104: | ||
GROUP BY n.nspname, c.relname, c.relkind | GROUP BY n.nspname, c.relname, c.relkind | ||
ORDER BY 4 desc limit 10; | ORDER BY 4 desc limit 10; | ||
+ | </ | ||
+ | |||
+ | ==== pgbadger ==== | ||
+ | [[https:// | ||
+ | |||
+ | === Parameters === | ||
+ | <code text> | ||
+ | --exclude-line | ||
+ | --include-query | ||
+ | --top (t) Number of top SQL queries | ||
+ | --sample-number (s) Number of example queries | ||
+ | --watch-mode (w) Only report errors | ||
+ | --begin (b) From this date ' | ||
+ | --end (e) To this date ' | ||
+ | --nocomment (C) Remove comments from queries | ||
+ | --dbclient (c) | ||
+ | --dbname (d) | ||
+ | --format (f) Log format | ||
+ | --jobs (j) | ||
+ | </ | ||
+ | |||
+ | === Examples === | ||
+ | <code bash> | ||
+ | # Display only country queries | ||
+ | pgbadger -f rds --include-query " | ||
+ | / | ||
+ | |||
+ | # Report only between certain times | ||
+ | pgbadger -b ' | ||
+ | | ||
+ | </ | ||
+ | [[PGBadgerReports| PGBadger Reports]]\\ | ||
+ | |||
+ | ==== pg_repack ==== | ||
+ | === AWS Instructions === | ||
+ | https:// | ||
+ | === Download === | ||
+ | For PostgreSQL 14 on AWS, use version 1.4.7. \\ | ||
+ | https:// | ||
+ | === Installation === | ||
+ | https:// | ||
+ | <code bash> | ||
+ | sudo apt install postgresql-server-dev-12 gcc zlib1g-dev | ||
+ | |||
+ | unzip pg_repack-1.4.5.zip | ||
+ | cd pg_repack-1.4.5 | ||
+ | make | ||
+ | sudo make install | ||
+ | </ | ||
+ | <code postgresql> | ||
+ | CREATE EXTENSION pg_repack; | ||
+ | </ | ||
+ | |||
+ | === Usage === | ||
+ | pg_repack will attempt to get an exclusive lock on the table being re-organised. \\ | ||
+ | If it can’t then, by default, it will attempt to terminate any sessions that are blocking it. \\ | ||
+ | |||
+ | Use option '' | ||
+ | |||
+ | <code bash> | ||
+ | cd pg_repack-1.4.5/ | ||
+ | ./pg_repack -k -h localhost -U postgres -D -t football.teams doob | ||
</ | </ |
postgresqlextensions.1632672013.txt.gz · Last modified: 2025/03/08 22:23 (external edit)