백업할때 sql/txt로 나오게 되니 압축하면서 하면 용량을 절약할 수 있다.

 

pg_dump dbname | gzip > filename.gz
Reload with:

gunzip -c filename.gz | psql dbname
or:

cat filename.gz | gunzip | psql dbname

[링크 : https://www.postgresql.org/docs/9.1/backup-dump.html]

[링크 : https://idchowto.com/?p=45509]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

데이터베이스 모델링  (0) 2020.01.17
subquery와 inner join  (0) 2020.01.16
postgresql 장치에 남은 공간이 없음  (0) 2020.01.15
postgresql 테이블 크기  (0) 2020.01.15
postgresql data_directory  (0) 2020.01.13
Posted by 구차니

스토리지 전체를 다 쓰기 전에 멈출줄 알았는데

다 쓰고 용량 없으니 DBMS 자체가 셧다운 되어버린다.

 

복구하는 법은.. 더 큰 볼륨으로 이동시키기 정도 뿐인걸로 검색이 되는데 다른 방법은 없는 건지 모르겠다.

[링크 : https://dba.stackexchange.com/questions/167515/dealing-with-disk-space-full-in-postgresql]

[링크 : https://www.postgresql.org/docs/9.1/disk-full.html]

[링크 : https://www.postgresql.org/docs/9.1/manage-ag-tablespaces.html]

 

+

 

[링크 : http://postgresql.kr/docs/9.4/continuous-archiving.html]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

subquery와 inner join  (0) 2020.01.16
pg_dump (postgresql backup, 백업)  (0) 2020.01.15
postgresql 테이블 크기  (0) 2020.01.15
postgresql data_directory  (0) 2020.01.13
postgres table의 물리적 용량 확인하기  (0) 2020.01.13
Posted by 구차니

테이블의 물리적 크기를 측정하는 방법

[링크 : https://www.a2hosting.com/.../postgresql/determining-the-size-of-postgresql-databases-and-tables]

 

table 별 table / index / toast(이게 먼지 모르겠음) 용량 byte와 MB 단위로 나오는 쿼리문

SELECT *, pg_size_pretty(total_bytes) AS total
    , pg_size_pretty(index_bytes) AS INDEX
    , pg_size_pretty(toast_bytes) AS toast
    , pg_size_pretty(table_bytes) AS TABLE
  FROM (
  SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
      SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
              , c.reltuples AS row_estimate
              , pg_total_relation_size(c.oid) AS total_bytes
              , pg_indexes_size(c.oid) AS index_bytes
              , pg_total_relation_size(reltoastrelid) AS toast_bytes
          FROM pg_class c
          LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
          WHERE relkind = 'r'
  ) a
) a;

[링크 : https://wiki.postgresql.org/wiki/Disk_Usage]

 

+

LZ 압축 기술로 압축하여 저장하는 공간인가?

 

TOAST(대형 속성 저장 기술:The Oversized-Attribute Storage Technique)

[링크 : http:// http://www.postgresql.org/docs/9.4/static/storage-toast.html]

[링크 : https://data-rider.blogspot.com/2015/07/postgresql-toast.html]

Posted by 구차니

실제 DB가 파일로 저장되는 경로를 확인하는 방법

 

show data_directory;

[링크 : https://confluence.curvc.com/pages/viewpage.action?pageId=10092649]

Posted by 구차니

byte 단위로 나오려나?

 

select pg_relation_size('schema.table_name');

[링크 : https://korearank1.tistory.com/43]

[링크 : https://wiki.postgresql.org/wiki/Disk_Usage]

 

+

byte가 맞는듯

pg_size_pretty()로 감싸면 읽기 편한 단위로 바꾸어 준다

[링크 : https://ktdsoss.tistory.com/383]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgresql 테이블 크기  (0) 2020.01.15
postgresql data_directory  (0) 2020.01.13
sql combination 생성하기  (0) 2020.01.13
postgres limits - max capacity  (0) 2020.01.10
pgmodeler  (0) 2020.01.05
Posted by 구차니

원래 글에서 응용해서 만들어 본 예제

4*3=12 개 나오는게 맞...겠지? 순열과 조합부터 다시 봐야하나 헷갈리네

 

select t1, t2
from (select unnest(array['a','b','c','d'])) as t1
join (select unnest(array['1','2','3'])) as t2 on t1 <> t2

[링크 : https://stackoverflow.com/questions/31129507/postgres-query-to-create-combinations]

 

t1과 t2가 동일 데이터가 있으면 안되기에 on에 조건을 true로 주면 문제없이 되긴 한다.

select t1, t2
from (select unnest(array['a','b'])) as t1
join (select unnest(array['1','2','3','a','as'])) as t2 on true

 

+

위의 예제에서 join on.. 대신 cross join 해도 되는 듯 하다

select t1, t2
from (select unnest(array['a','b','c','d'])) as t1
cross join (select unnest(array['1','2','3'])) as t2

[링크 : https://www.essentialsql.com/cross-join-introduction/]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgresql data_directory  (0) 2020.01.13
postgres table의 물리적 용량 확인하기  (0) 2020.01.13
postgres limits - max capacity  (0) 2020.01.10
pgmodeler  (0) 2020.01.05
스칼라 서브쿼리(scalar subquery)  (0) 2020.01.04
Posted by 구차니

row 수는 pages에 영향을 받지만 실질적으로 무제한에 가까울듯 하고

column 수도 single page에 영향을 받아서 1600 이라고는 하지만 그것보다 적을수 있다고 하니

은근히 계산이 까다로울 듯.. 한 페이지가 얼마냐.. -_-

 

Table K.1. PostgreSQL Limitations

ItemUpper LimitComment

database size unlimited  
number of databases 4,294,950,911  
relations per database 1,431,650,303  
relation size 32 TB with the default BLCKSZ of 8192 bytes
rows per table limited by the number of tuples that can fit onto 4,294,967,295 pages  
columns per table 1600 further limited by tuple size fitting on a single page; see note below
field size 1 GB  
identifier length 63 bytes can be increased by recompiling PostgreSQL
indexes per table unlimited constrained by maximum relations per database
columns per index 32 can be increased by recompiling PostgreSQL
partition keys 32 can be increased by recompiling PostgreSQL

The maximum number of columns for a table is further reduced as the tuple being stored must fit in a single 8192-byte heap page. For example, excluding the tuple header, a tuple made up of 1600 int columns would consume 6400 bytes and could be stored in a heap page, but a tuple of 1600 bigint columns would consume 12800 bytes and would therefore not fit inside a heap page. Variable-length fields of types such as text, varchar, and char can have their values stored out of line in the table's TOAST table when the values are large enough to require it. Only an 18-byte pointer must remain inside the tuple in the table's heap. For shorter length variable-length fields, either a 4-byte or 1-byte field header is used and the value is stored inside the heap tuple.

Columns that have been dropped from the table also contribute to the maximum column limit. Moreover, although the dropped column values for newly created tuples are internally marked as null in the tuple's null bitmap, the null bitmap also occupies space.

[링크 : https://www.postgresql.org/docs/12/limits.html]

 

[링크 : https://link.springer.com/content/pdf/bbm%3A978-1-4302-0018-5%2F1.pdf]

[링크 : https://soapware.screenstepslive.com/.../22071-q-what-is-the-postgresql-database-top-capacity]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgres table의 물리적 용량 확인하기  (0) 2020.01.13
sql combination 생성하기  (0) 2020.01.13
pgmodeler  (0) 2020.01.05
스칼라 서브쿼리(scalar subquery)  (0) 2020.01.04
array_cat()  (0) 2019.12.30
Posted by 구차니

대충 만져보는데.. ctgov에서 export한 형상이 이걸로 만든건가 싶네?

[링크 : https://aact.ctti-clinicaltrials.org/schema]

 

아무튼.. constraints를 걸지 않고 바로 그릴수는 없는지 찾는데 잘 보이진 않네..

[링크 : https://pgmodeler.io/]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

sql combination 생성하기  (0) 2020.01.13
postgres limits - max capacity  (0) 2020.01.10
스칼라 서브쿼리(scalar subquery)  (0) 2020.01.04
array_cat()  (0) 2019.12.30
테이블 내 두 컬럼 값 바꾸기(임시 변수)  (0) 2019.12.24
Posted by 구차니

말은 거창한데.. SELECT * FROM

에서 * 부분에 쓰는 한줄짜리 리턴하는 서브쿼리이다.

 

[링크 : https://ttend.tistory.com/623]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgres limits - max capacity  (0) 2020.01.10
pgmodeler  (0) 2020.01.05
array_cat()  (0) 2019.12.30
테이블 내 두 컬럼 값 바꾸기(임시 변수)  (0) 2019.12.24
left join이 능사는 아니다  (0) 2019.12.24
Posted by 구차니

sublime editor에서 선택하고 alt 엔터 눌러서 동시에 편집하는 기능과 유사한 것 같은데

어떻게 발동(?)하는지 조건을 모르겠다.

 

 

+

해보니.. 마우스로 일일이 하나하나 ctrl - 클릭해서 선택해서 동시에 입력이 된다.

이 부분만큼은 sublime의 승리구만..

 

[링크 : https://stackoverflow.com/questions/3453151/notepad-multi-editing/37930797]

Posted by 구차니