Check Postgres Schema Size

SELECT nspname AS schema_name,SUM(pg_total_relation_size(quote_ident(nspname) || ‘.’ || quote_ident(relname))) AS total_size_bytes,pg_size_pretty(SUM(pg_total_relation_size(quote_ident(nspname) || ‘.’ || quote_ident(relname)))) AS total_sizeFROM pg_classJOIN pg_namespace ON relnamespace = pg_namespace.oidGROUP BY nspnameORDER BY total_size_bytes DESCLIMIT 20;

Big Query Loading

Using Google SDK Ensure gcloud project is set correctly gcloud config set project myProject Copy out JSON (sed to remove empty quotes) psql -h servername -U username -c \ 2 “\COPY (SELECT json_build_object(‘toid’, toid, ‘theme’, theme, ‘descriptivegroup’, descriptivegroup, ‘descriptiveterm’, descriptiveterm, 3 ‘featurecode’, featurecode, ‘geog’, ST_AsGeoJSON(ST_Transform(geom, 4326)::geography, 8, 0)) AS geog 4 FROM (SELECT featurecode, descriptiveterm, … More Big Query Loading

GIT and line endings!

Referenced from another site but copied for personal reference: core.autocrlf If you’re programming on Windows and working with people who are not (or vice-versa), you’ll probably run into line-ending issues at some point. This is because Windows uses both a carriage-return character and a linefeed character for newlines in its files, whereas macOS and Linux … More GIT and line endings!

Formatting and mounting a zonal persistent disk

1.list attached disks sudo lsblk 2.Format the disk using the mkfs tool sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/[DEVICE_ID] (This command deletes all data from the specified disk, so make sure that you specify the disk device correctly. To maximize disk performance, use the recommended formatting options in the -E flag. It is not necessary … More Formatting and mounting a zonal persistent disk

pg_hba.conf

locate pg_hba.conf   sudo vi /etc/postgresql/9.6/main/pg_hba.conf if need to add remote host go to remote server and try and psql to gcp box. i.e ssh to remote host and run psql -h **.***.***.** -U user database this will fail with the below error “error: could not connect to server: FATAL: no pg_hba.conf entry for host … More pg_hba.conf