This file contains 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
fabrizio=# \db+ | |
List of tablespaces | |
Name | Owner | Location | Access privileges | Options | Size | Description | |
------------+----------+----------+-------------------+---------+--------+------------- | |
pg_default | fabrizio | | | | 27 MB | | |
pg_global | fabrizio | | | | 496 kB | | |
(2 rows) | |
fabrizio=# create tablespace tb1 location '/tmp/tablespace'; | |
CREATE TABLESPACE |
This file contains 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 array_remove (anyarray, anyarray) RETURNS anyarray | |
AS $$ | |
SELECT array( | |
SELECT e | |
FROM unnest($1) AS s(e) | |
WHERE NOT e = ANY($2) | |
); | |
$$ | |
LANGUAGE sql; |
This file contains 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 | |
# | |
# O pgbadger no modo incremental gera um indice (arquivos .bin) | |
# para fazer o parser do log, e não possui um mecanismo interno | |
# de limpeza de arquivos que não estão mais em uso. | |
# | |
# Este script efetua a limpeza dos .bin obsoletos, ou seja, | |
# aqueles que são de dias anteriores aos correspondentes a | |
# semana corrente. |
This file contains 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 bytea_import(filename text) RETURNS bytea AS | |
$$ | |
import os | |
with open(filename, 'r') as f: | |
s = f.read() | |
return s | |
$$ | |
LANGUAGE 'plpythonu' VOLATILE; |
This file contains 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
/* | |
* | |
* Desafio do Henrique Bastos () | |
* | |
* Dado uma lista de números e um número k, retorne se quaisquer dois números da lista | |
* somados resultam no número k. | |
* | |
* Por exemplo, dado [10, 15, 3, 7] e k = 17, retorne verdadeiro, já que 10 + 7 = 17. | |
* | |
* Passe pelos números da lista uma única vez. |
This file contains 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
static_resources: | |
listeners: | |
- name: postgres_listener | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 5432 | |
listener_filters: | |
- name: envoy.filters.listener.original_src | |
typed_config: |
This file contains 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
ssl = off | |
maintenance_work_mem = 2GB | |
work_mem = 2GB | |
fsync = off | |
synchronous_commit = off | |
wal_level = minimal | |
max_wal_senders = 0 | |
archive_mode = off | |
wal_buffers = -1 | |
wal_writer_delay = 20ms |
This file contains 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
-- https://psutil.readthedocs.io/en/latest/#psutil.Process.memory_full_info | |
-- Linux: 0=rss, 1=vms, 2=shared, 3=text, 4=lib, 5=data, 6=dirty, 7=uss, 8=pss, 9=swap | |
CREATE OR REPLACE FUNCTION get_memory_info(pid INTEGER DEFAULT NULL, memtype INTEGER DEFAULT 0) | |
RETURNS BIGINT | |
AS | |
$$ | |
import psutil | |
p = psutil.Process(pid) | |
return p.memory_full_info()[memtype] | |
$$ |
This file contains 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
/* | |
* search_in_tables | |
* | |
* Usage example: | |
* SELECT * FROM search_in_tables('public', 'foo', '%pattern%'); | |
* | |
*/ | |
CREATE OR REPLACE FUNCTION search_in_tables( | |
IN ptable_schema TEXT, | |
IN ptable_name TEXT, |
This file contains 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 EXTENSION dblink; | |
-- customize start | |
CREATE SERVER pgbouncer FOREIGN DATA WRAPPER dblink_fdw OPTIONS (host '172.17.10.95', | |
port '6432', | |
dbname 'pgbouncer'); | |
CREATE USER MAPPING FOR PUBLIC SERVER pgbouncer OPTIONS (user 'postgres'); | |
-- customize stop |
OlderNewer