Skip to content

Instantly share code, notes, and snippets.

@robsmith1776
robsmith1776 / pgFormatDate.js
Created August 11, 2022 01:59 — forked from jczaplew/pgFormatDate.js
Javascript Date to Postgres-acceptable format
// Convert Javascript date to Pg YYYY MM DD HH MI SS
function pgFormatDate(date) {
/* Via http://stackoverflow.com/questions/3605214/javascript-add-leading-zeroes-to-date */
function zeroPad(d) {
return ("0" + d).slice(-2)
}
var parsed = new Date(date)
@robsmith1776
robsmith1776 / README.md
Created September 29, 2022 17:12 — 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:

Mac install Nerd Font (Fire code)

brew cask
brew tap homebrew/cask-fonts 
brew install font-fira-code
brew install font-Fira-Code-nerd-font
brew install font-hack-nerd-font
@robsmith1776
robsmith1776 / Dockerfile
Created December 8, 2022 22:13 — forked from tym-xqo/Dockerfile
pg_service.conf + psycopg2 example
FROM python:3-alpine
# install requirements for psycopg2
RUN apk update && apk add -u \
postgresql-dev \
gcc \
python3-dev \
musl-dev
RUN pip3 install psycopg2
@robsmith1776
robsmith1776 / journalctl.txt
Created July 7, 2023 15:04 — forked from MrAndrewMal/journalctl.txt
How to read live-tail logs of multiple services with journalctl
#Systemd - How to read live-tail logs of multiple services with journalctl
sudo journalctl --follow _SYSTEMD_UNIT=docker.service + _SYSTEMD_UNIT=apache2.service