Skip to content

Instantly share code, notes, and snippets.

View ferrao's full-sized avatar
🎯
Focusing

Rui Ferrão ferrao

🎯
Focusing
View GitHub Profile
@ferrao
ferrao / git-gist.md
Last active May 24, 2021 15:11
Git most used

Update fork from upstream

git fetch upstream master
git merge upstream/master

Deploy from branch

Overwrite local staging branch (tracking upstream) with master(upstream fork) :

@ferrao
ferrao / README.md
Created March 10, 2022 22:59 — forked from valyala/README.md
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
### Keybase proof
I hereby claim:
* I am ferrao on github.
* I am ruiferrao (https://keybase.io/ruiferrao) on keybase.
* I have a public key whose fingerprint is 6AB8 59DC 20D4 1D18 FCF8 C6DE 42E7 636B CF77 1773
To claim this, I am signing this object:
@ferrao
ferrao / gpg
Created March 29, 2024 22:16
GPG
# Encrypt files, not caching password
gpg -c --no-symkey-cache file.txt
# decrypt files, not caching password
gpg --no-symkey-cache file.txt.gpg