Forwarded from Sysadmin Tools 🇺🇦
Прислали в лс ништяков для postgresql
1) http://pgconfigurator.cybertec.at/
2) https://pgtune.leopard.in.ua/#/
3) https://github.com/jfcoz/postgresqltuner
1) http://pgconfigurator.cybertec.at/
2) https://pgtune.leopard.in.ua/#/
3) https://github.com/jfcoz/postgresqltuner
pgtune.leopard.in.ua
PGTune - calculate configuration for PostgreSQL based on the maximum performance for a given hardware configuration
PgTune - Tuning PostgreSQL config by your hardware
#table fragmentation (#monitoring)
SELECT schemaname,
tablename,
dead_tuple_count(stats) AS dead_tuples,
pg_size_pretty(dead_tuple_len(stats)) AS dead_space,
pg_size_pretty(free_space(stats)) AS free_space,
last_autovacuum,
last_autoanalyze
FROM
(SELECT pgt.schemaname AS schemaname,
pgt.tablename AS tablename,
pgstattuple(pgt.schemaname || '.' || pgt.tablename)
AS stats,
uts.last_autovacuum AS last_autovacuum,
uts.last_autoanalyze AS last_autoanalyze
FROM pg_tables AS pgt
LEFT JOIN pg_stat_user_tables
AS uts
ON pgt.schemaname = uts.schemaname
AND pgt.tablename = uts.relname
WHERE pgt.schemaname NOT IN ('repack','pg_catalog')) AS r
ORDER BY dead_tuples DESC;
#index fragmentation (#monitoring)
SELECT schemaname,
indexname,
tablename,
dead_tuple_count(stats) AS dead_tuples,
pg_size_pretty(dead_tuple_len(stats)) AS dead_space,
pg_size_pretty(free_space(stats)) AS free_space
FROM
(SELECT pgt.schemaname AS schemaname,
pgt.indexname AS indexname,
pgt.tablename AS tablename,
pgstattuple(pgt.schemaname || '.' || pgt.indexname) AS stats
FROM pg_indexes AS pgt
WHERE pgt.schemaname NOT IN ('repack',
'pg_catalog')
AND pgt.indexname NOT IN ('some',
'important',
'triggers')) AS r
ORDER BY dead_tuples DESC;
#index https://www.cybertec-postgresql.com/en/what-is-fillfactor-and-how-does-it-affect-postgresql-performance/
CYBERTEC PostgreSQL | Services & Support
What is fillfactor and how does it affect PostgreSQL performance?
In this blog posting you find out: What is fillfactor and how does it affect PostgreSQL performance? | Effects & Testing
#json #constraint
create table books(k serial primary key, doc jsonb not null);
insert into books(doc) values
('
{ "ISBN" : 4582546494267,
"noscript" : "Macbeth",
"author" :
{"given_name": "William",
"family_name": "Shakespeare"},
"year" : 1623
}
');
alter table books
add constraint books_doc_is_object
check(
jsonb_typeof(doc) is not null and
jsonb_typeof(doc) = 'object'
);
alter table books
add constraint books_doc_isbn_ok
check(
doc->>'ISBN' is not null and
jsonb_typeof(doc->'ISBN') = 'number' and
(doc->>'ISBN')::bigint > 0 and
length(doc->>'ISBN') = 13
);
#storage TOAST strategy: PLAIN, EXTENDED, EXTERNAL, MAIN
https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-ONDISK
https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-ONDISK
PostgreSQL Documentation
66.2. TOAST
66.2. TOAST # 66.2.1. Out-of-Line, On-Disk TOAST Storage 66.2.2. Out-of-Line, In-Memory TOAST Storage This section provides an overview of TOAST (The …
#query #null https://www.cybertec-postgresql.com/en/a-postgresql-story-about-null-is-null-null-and-not-null/
CYBERTEC
A PostgreSQL story about "NULL IS NULL = NULL AND NOT NULL"
Why the word "unknown" is better to describe a NULL value than "empty". Basic rules for handling NULL values in PostgreSQL.
