Skip to content

Instantly share code, notes, and snippets.

@joelonsql
joelonsql / PostgreSQL-EXTENSIONs.md
Last active October 25, 2025 13:15
1000+ PostgreSQL EXTENSIONs

🗺🐘 1000+ PostgreSQL EXTENSIONs

This is a list of URLs to PostgreSQL EXTENSION repos, listed in alphabetical order of parent repo, with active forks listed under each parent.

⭐️ >= 10 stars
⭐️⭐️ >= 100 stars
⭐️⭐️⭐️ >= 1000 stars
Numbers of stars might not be up-to-date.

@JayBeavers
JayBeavers / SSHA512_gen.py
Created April 26, 2020 02:08
Create a salted SHA512 password hash for use with Dovecot, updated for python 3
#!/usr/bin/python
import os
import hashlib
import getpass
import base64
password1 = None
password2 = None
@k-caps
k-caps / compare.csv
Last active August 8, 2025 12:14
pg agent vs pg cron
pg_cron pgAGent
GUI no yes
CLI yes no
Complex scheduling Standard crontab; one cron entry per execution (of command [sql or plpgsql] or.sql file Multiple steps per entry; multiple schedules for the same step without duplicating it
Requires extra software extension in shared_preload_libraries; installed via yum or similar pgAdmin is required to manage jobs; installed via yum or similar; runs as a separate daemon
Runs inside the database yes Jobs are stored in the database but are managed externally via pgAdmin; scheduling is run via the external daemon
Can be run without sSQL knowledge no yes
Requires Postgres cluster restart yes no
@parallelo3301
parallelo3301 / utils.sql
Last active May 6, 2024 02:56
PostgreSQL utils
-- v5
----------------------------------------------------------- basic instance info
-- show db version
SELECT version();
-- uptime
SELECT pg_postmaster_start_time();
-- show connections
@pirate
pirate / docker-compose-backup.sh
Last active October 9, 2025 12:11
Backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases.
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
@ThomasLeister
ThomasLeister / rspamd-whitelisting.md
Last active August 5, 2025 18:18
How to whitelist IP addresses or domains in Rspamd

Whitelist IP addresses based on pre-filter policy

/etc/rspamd/local.d/multimap.conf:

  IP_WHITELIST {
      type = "ip";
      prefilter = true;
      map = "/${LOCAL_CONFDIR}/local.d/ip_whitelist.map";
 action = "accept";
@supix
supix / postgres_recovery.md
Last active March 24, 2025 12:46
Postgres error: Missing chunk 0 for toast value in pg_toast

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.

@NikolayS
NikolayS / pg_terminate_old.sql
Last active June 21, 2018 02:02
Terminate old Postgres sessions
-- This function terminates all Postgres sessions which state have been changed "age" minutes ago.
-- Usage example:
-- select * from flush_connections(60);
--
-- Or just (but result will be less readable):
-- select flush_connections(60);
--
-- By default, terminates only sessions with "state = 'idle'".
-- If needed, you can terminate ALL sessions, regardless of their states:
-- select * from flush_connections(60, true);
@osiloke
osiloke / doveadmpw.go
Last active August 21, 2022 08:06
This generate a dovecot password in golang, inspired by https://gist.github.com/garrettreid/8329796
package main
import (
"crypto/sha512"
"encoding/base64"
"fmt"
"math/rand"
"time"
)
@oinopion
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;