Skip to content

Instantly share code, notes, and snippets.

@NerOcrO
Last active August 27, 2022 06:59
Show Gist options
  • Save NerOcrO/c26a663c57b99761e4fe5aef17414fc1 to your computer and use it in GitHub Desktop.
Save NerOcrO/c26a663c57b99761e4fe5aef17414fc1 to your computer and use it in GitHub Desktop.
postgresql sql
  • https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server
  • https://pgtune.leopard.in.ua/
  • A priori, on ne peut pas avoir les logs en stdout...
  • SHOW config_file pour voir où est le fichier de config
  • docker exec -it pc-postgres cat /var/lib/postgresql/data/postgresql.conf
  • docker exec -it pc-postgres cat /var/lib/postgresql/data/log/postgresql-2020-03-16_144749.log
  • docker exec -it pc-postgres tail -f /var/lib/postgresql/data/log/postgresql-2020-03-17_103605.log
  • SELECT * FROM pg_matviews WHERE matviewname = 'discovery_view';

Bonnes pratiques

  • Ne pas avoir trop de jointure (et donc moins de table)
  • Avoir un index sur les join/where et order by/group by (si nécessaire)
  • Parallélisme
  • Ne pas faire de ALTER lors d'une migration car ça pose un lock (ZDD) en version 10 mais en 11, ça passe mieux.
  • https://www.notion.so/Clarifier-les-pratiques-de-migration-de-BDD-776f9b4a6d90423ba576c9840404c11f
  • OUTER JOIN ne sera pas plus lent que INNER JOIN sur un test avec quelques dizaines de lignes
  • psql -U [USER] [DB]
  • SET search_path TO [SCHEMA];
  • ou sinon SELECT * FROM [SCHEMA].notification;
  • le point virgule est super important !
  • \dt pour voir les tables
  • \dT pour voir les énumération

Outils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment