postgresqlcommands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| postgresqlcommands [2022/05/19 15:13] – z0hpvk | postgresqlcommands [2025/04/17 10:16] (current) – z0hpvk | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== Installation ==== | ==== Installation ==== | ||
| - | === Ubuntu | + | === Linux === |
| - | [[https:// | + | [[https:// |
| + | [[https:// | ||
| === Create Cluster === | === Create Cluster === | ||
| - | The installation | + | The Debian or Ubuntu |
| - | If you wish to create a new one run the following command as postgres | + | Create |
| + | <code bash> | ||
| + | # Debian / Ubuntu | ||
| + | pg_createcluster -d / | ||
| + | |||
| + | # Redhat / Fedora | ||
| + | # Default Data Directory: / | ||
| + | sudo / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | === Instance Details === | ||
| < | < | ||
| - | pg_createcluster | + | / |
| + | / | ||
| + | /usr/ | ||
| </ | </ | ||
| Line 114: | Line 128: | ||
| SELECT PG_SIZE_PRETTY (PG_TOTAL_RELATION_SIZE(' | SELECT PG_SIZE_PRETTY (PG_TOTAL_RELATION_SIZE(' | ||
| SELECT PG_SIZE_PRETTY (PG_DATABASE_SIZE(' | SELECT PG_SIZE_PRETTY (PG_DATABASE_SIZE(' | ||
| + | |||
| + | -- Partitioned / Inherited Tables | ||
| + | SELECT pi.inhparent:: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | FROM pg_catalog.pg_statio_user_tables psu | ||
| + | JOIN pg_class pc ON psu.relname = pc.relname | ||
| + | JOIN pg_database pd ON pc.relowner = pd.datdba | ||
| + | JOIN pg_inherits pi ON pi.inhrelid = pc.oid | ||
| + | WHERE pd.datname = ' | ||
| + | GROUP BY pi.inhparent | ||
| + | ORDER BY sum(pg_total_relation_size(psu.relid)) DESC; | ||
| SELECT RELNAME, PG_SIZE_PRETTY (PG_TABLE_SIZE(RELID)) AS TABLE_SIZE | SELECT RELNAME, PG_SIZE_PRETTY (PG_TABLE_SIZE(RELID)) AS TABLE_SIZE | ||
| Line 164: | Line 192: | ||
| -- Populate table with random Ids | -- Populate table with random Ids | ||
| - | CREATE TABLE T1 (id integer); | + | CREATE TABLE t1 (id integer); |
| - | INSERT INTO T1 SELECT * FROM generate_series(1, | + | INSERT INTO t1 SELECT * FROM generate_series(1, |
| + | |||
| + | CREATE TABLE t2 (id integer, description text, updated timestamptz); | ||
| + | INSERT INTO t2 | ||
| + | SELECT floor(random()*(100-1+1))+1 AS random_number, | ||
| + | | ||
| + | now() - INTERVAL '1 year' + random() * (now() - now() - INTERVAL '1 year') AS random_timestamp | ||
| + | FROM generate_series(1, | ||
| -- Reload postgresql.conf and pg_hba.conf Files | -- Reload postgresql.conf and pg_hba.conf Files | ||
postgresqlcommands.1652973227.txt.gz · Last modified: (external edit)
