-
No postgresql.conf do primário:
wal_level = 'hot_standby' max_wal_senders = 5
-
Adicionar no
pg_hba.conf
do primário e reiniciar:local replication postgres trust
-
Para secundário e limpar tudo (cuidado com o
rm
):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$ | |
DECLARE | |
r RECORD; | |
ret BOOLEAN; | |
cmd TEXT; | |
check_table regclass = '<table name here>'::regclass; | |
BEGIN | |
FOR r IN | |
SELECT | |
c.conname, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* One random row from table "tbl" */ | |
WITH RECURSIVE r AS ( | |
SELECT NULL::int AS id, min(id) AS min_id, max(id) AS max_id, 0 AS cnt | |
FROM tbl | |
UNION ALL | |
SELECT tbl.id, r.min_id, r.max_id, r.cnt + 1 | |
FROM r LEFT JOIN tbl | |
ON tbl.id = (SELECT floor(random() * (r.max_id - r.min_id + 1))::int) | |
WHERE r.id IS NULL | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o pipefail | |
PROCESS_TIMEOUT_SEC=7200 | |
VACUUM_FREEZE_TABLE_AGE=150000000 # 150M | |
VACUUM_FREEZE_MIN_AGE=50000000 # 50M | |
START_TIME_EPOCH=$( date +%s ) | |
END_TIMEOUT_EPOCH=$(( ${START_TIME_EPOCH} + ${PROCESS_TIMEOUT_SEC} )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH temp_dirs AS ( | |
SELECT s1.dir || s1.version || '/pgsql_tmp' AS dir_name | |
FROM | |
( | |
SELECT | |
'pg_tblspc/' || spc.oid::text || '/' AS dir, | |
l.version | |
FROM | |
( | |
SELECT spc1.oid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION wm_concat_finalfn(anyarray) | |
RETURNS text | |
LANGUAGE SQL | |
IMMUTABLE AS $$ | |
SELECT array_to_string($1, ','); | |
$$; | |
DROP AGGREGATE IF EXISTS wm_concat(anyelement); | |
CREATE AGGREGATE wm_concat(anyelement) ( |
This is a very simple script, so don't expect something great.
You can change it, distribute, do whatever you like, I don't mind. But if you improve it, you could share it back ;)
To use, you have to export variables to use aws-cli, like AWS_PROFILE
, AWS_DEFAULT_REGION
, etc. Then just call the script using watch
(or however you like) and giving the RDS instance name:
watch ./rds-top.sh <your instance name>
Requirements:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple example to read CSV format from nomes.csv at https://brasil.io/dataset/genero-nomes/files/ | |
package main | |
import ( | |
"encoding/csv" | |
"fmt" | |
"os" | |
"strconv" | |
"strings" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Este arquivo contém o histórico de TODOS comandos que executei durante o treinamento. | |
* Pode conter alguns erros e falhas, mas fica aqui caso eu tenha esquecido de deixar algum exemplo | |
* mais claro nos demais arquivos. | |
*/ | |
select '{"a":1, "b":2}'::jsonb @> '{"b":2}'::jsonb; | |
\e | |
select '{"a":1, "b":2}'::jsonb; | |
select '{"a":1, "b":2, "b": 3}'::json; | |
select '{"a":1, "b":2, "b": 3}'::json -> 'b'; |
Tutorial de instalação Warsaw no Fedora
-
Baixar o arquivo warsaw_setup64.deb direto do site do banco, vou considerar que está salvo em
~/Downloads/warsaw_setup_64.deb
(ajuste de acordo caso esteja em outro local) -
Iniciar toolbox (dá pra fazer sem o toolbox, mas eu prefiro pelas dependências):
$ toolbox create -c itau $ toolbox enter -c itau
OlderNewer