query all table size in postgresql
2024-05-06
query table size
2024-05-05
query database size
2024-05-03
How to install PostgreSQL Client on AWS EC2
2024-01-02
由於公司現在是用 Postgres Database 既關係… 很多時都會用到 Postgres 的 PSQL tools 來做一些 operations… 當有新同事 / 新 intern 開始接觸公司的project 時多數都會遇到安裝問題… 我們會用docker 來 run Postgres Database 的 所以不用在主機安裝 Postgres Database Engine 解決方法 我們只需要到以下網扯 https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 下載 之後在安裝過程選擇 postgres sql client tools 便可.. postgres sql client tools
2023-06-01
今日想同大家分享一個 PostgresSQL Database maintenance script 用來 reclaim 返 D space 解決方法: VACUUM (FULL, FREEZE, VERBOSE, ANALYZE, SKIP_LOCKED, INDEX_CLEANUP, TRUNCATE); hope you find it useful
2022-08-13
之前 個Website down 之後發現原來係 PostgresSQL connection 爆左.. 所以個server 唔可以再make connection… 想知道個SQL D connection 用左幾多… Stackoverflow 完之後搵到一個 PSQL 既 query, 可以用黎 check 下用緊幾多connection 同仲有幾多connection remain https://dba.stackexchange.com/questions/161760/number-of-active-connections-and-remaining-connections 解決方法: select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal from (select count(*) used from pg_stat_activity) t1, (select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2, (select setting::int max_conn from pg_settings where name=$$max_connections$$) t3 hope you find it useful
2022-07-20
有時候個SQL script 太大.. 如果用 SQL editor 去 run 個 .sql file 好大機會 會crash 我地可以用 command 來 execute 呢個 .sql 我就用呢個方法去Restore database backup 解決方法: psql -h [`hostname`] -U [`username`] -d [`database_name`] -f [`sql_script.sql`] psql -h localhost -U postgres -d local-db -f dump-local-db-20220701150001.sql hope you find it useful
2022-07-03
如果想幫 PostgresSQL 做個database backup 之後係 SQL Editor 上..load 返呢個 SQL backup file 我地可以用 pg_dump 去backup 個 database 用佢個 insert statement option 便可 解決方法: pg_dump --verbose --host=[`hostname`] --port=[`port`] --username=[`username`] --format=p --encoding=UTF-8 --inserts --no-owner --file [`filename`].sql -n "public" [`database_name`] pg_dump --verbose --host=localhost --port=5432 --username=postgres --format=p --encoding=UTF-8 --inserts --no-owner --file dump-local-db-$(date '+%Y%m%d%H%M%S').sql -n "public" local-db hope you find it useful
2022-07-02
如何在 postgresql 上rebuild database index REINDEX DATABASE "database-name"; Hope you find it useful
2022-06-27