Как узнать размер таблиц в postgresql

SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" 
FROM pg_class C 
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) 
WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname !~ '^pg_toast' 
ORDER BY pg_total_relation_size(C.oid) DESC 
LIMIT 100;

Обслуживание PostgreSql

Examples

In the examples below, [tablename] is optional. Without a table specified, VACUUM will be run on available tables in the current schema that the user has access to.

  1. Plain VACUUM: Frees up space for re-use
VACUUM [tablename]
  1. Full VACUUM: Locks the database table, and reclaims more space than a plain VACUUM
/* Before Postgres 9.0: */ 
VACUUM FULL 
/* Postgres 9.0+: */ 
VACUUM(FULL) [tablename]
  1. Full VACUUM and ANALYZE: Performs a Full VACUUM and gathers new statistics on query executions paths using ANALYZE
/* Before Postgres 9.0: */ 
VACUUM FULL ANALYZE [tablename] 
/* Postgres 9.0+: */ 
VACUUM(FULL, ANALYZE) [tablename]
  1. Verbose Full VACUUM and ANALYZE: Same as #3, but with verbose progress output
/* Before Postgres 9.0: */ 
VACUUM FULL VERBOSE ANALYZE [tablename] 
/* Postgres 9.0+: */ 
VACUUM(FULL, ANALYZE, VERBOSE) [tablename]
Читать далее «Обслуживание PostgreSql»

Работа с часовыми поясами

Все сервера должны быть в одном часовом поясе и настроить их можно по инструкциям ниже:

Далее в nodejs нужно добавить код для преобразования даты:

var moment = require('moment');
...
Date.prototype.toJSON = function () { return moment(this).format('YYYY-MM-DDTHH:mm:ss.SSSZZ'); }

Настройка временной зоны на Ubuntu 18

В systemd есть своя утилита для настройки даты и часового пояса. Чтобы узнать текущее состояние выполните:

timedatectl status

Для просмотра всех доступных временных зон выполните такую команду:

Читать далее «Настройка временной зоны на Ubuntu 18»

Автоматическое документирование базы данных

Для документирование базы данных применяется открытое решение Autodoc.

Инструкция по установке и настройке на сайте appcode.pw

Основной скрипт для запуска генерации документации.

cd autodoc
postgresql_autodoc -d cic-dev-db -h 192.168.17.111 -u postgres --password=<pw> -t html -s "core|dbo" -f /var/www/html/cic-dev-db

Демонстрационный вариант документации можно посмотреть на сайте http://cic.it-serv.ru/cic-dev-db.html

Autodoc для postgresql

Ставим приложение autodoc

$ sudo apt install libdbi-perl libhtml-template-perl libterm-readkey-perl libdbd-pg-perl
$ git clone https://github.com/cbbrowne/autodoc.git
$ cd autodoc
$ sudo make install

Дальше запускаем скрипт

postgresql_autodoc -d cic-dev-db -h 192.168.17.111 -u postgres --password -t html -s core -f cic-dev-db-core

Примечание: схемы можно передать как

-s "core|dbo"

Исходный код: https://github.com/cbbrowne/autodoc