반응형 DBMS/PostgreSQL24 [PostgreSQL] dead tuple 모니터링 시 주의(vacuum full) DBMS: PostgreSQL 14.9- vacuum full 수행 시 pg_stat_all_tables 값(n_live_tup, n_dead_tup) 변경안됨(dead tuple 모니터링 시 주의)- vacuum 수행 시 pg_stat_all_tables 값(n_live_tup, n_dead_tup) 변경됨[목차여기]VACUUM FULL 수행 시 n_dead_tup 값 변화delete 작업으로 데이터 삭제하여 dead tuple 발생 후vacuum full 수행 시 실제 사이즈는 줄어 dead tuple 삭제가 되었지만pg_stat_all_tables의 n_live_tup, n_dead_tup 값은 변경되지 않고ANALYZE 명령으로 통계 갱신 후 업데이트가 되는 것을 확인 할 수 있.. 2024. 4. 21. [PostgreSQL] postgres 계정 로그인 불가 single 모드 복구 (FATAL: role "postgres" is not permitted to log in) DBMS: PostgreSQL 14.9 postgres계정처럼 superuser의 login 권한을 제거하였을 경우 접속이 불가한 경우 해결하는 방법입니다 싱글모드로 접속하여 postgres 계정에 grant 문을 통한 권한 부여로 복구합니다 [목차여기] postgres 계정 권한 제거 superuser인 postgres 계정의 login 권한을 제거한 후 테스트 시 접속 실패합니다 -- postgres(super user)로그인 권한 제거 postgres=# alter user postgres nologin ; ALTER ROLE postgres=# \du List of roles Role name | Attributes | Member of -------------+-------------------.. 2024. 4. 19. [PostgreSQL] ERROR: current transaction is aborted 에러 해결 법 DBMS: PostgreSQL 14.9 - BEGIN 명령을 통한 트랜잭션 진행 중 ERROR 발생 시 이후 모든 명령은 에러 발생함 ERROR: current transaction is aborted, commands ignored until end of transaction block - commit 또는 rollback 후 정상 작동 [목차여기] 테스트 테이블 생성 postgres=# create table t1 as select * from pg_tables ; SELECT 66 postgres=# postgres=# select count(*) from t1 ; count ------- 66 (1 row) 테스트 postgresql은 기본 autocommit 으로 작동합니다. 수동으로 begin.. 2024. 4. 7. [PostgreSQL] pg_dump 파일에서 테이블명 변경하여 복구 DBMS: PostgreSQL 14.9 pg_dump로 백업받은 파일에서 특정 테이블 이름을 변경하여 복구하고자 하는 경우 오라클의 datapump에서의 remap 기능을 현재 PostgreSQL은 지원하지 않습니다 - text format으로 받은 경우 스크립트 수정하여 실행 - custom format으로 받은 경우 스크립트 추출하여 내용 변경 후 실행 - pg_restore -t 옵션 사용 시 해당 오브젝트만 추출(관련 인덱스 등 안나옴)되므로 주의 명령어 예시 -- sk1.dmp 파일에서 tab1 테이블 tab2_all.sql 파일로 추출 pg_restore -f tab2_all.sql -n public -t tab1 sk1.dmp 이번 포스팅은 커스텀 포멧의 백업파일에서 스크립트 추출 후 테이블.. 2024. 3. 12. [PostgreSQL] WAL 경로 변경하는법 DBMS: PostgreSQL 14.9 [목차여기] 초기생성 시 wal 경로 지정 initdb -D /pg_data -E'UTF8' --locale=en_US.utf8 --waldir=/pg_wal 또는 이미 생성된 기존 경로 변경 시 아래와 같은 순서로 작업 진행 1. pg_ctl stop 2. 신규 경로 디렉토리 생성(/pg_wal) 및 권한 부여 3. 기존 경로 파일 이동($PGDATA/pg_wal -> /pg_wal) 4. 심볼릭 링크 생성 4.1 기존 디렉토리 삭제 (rm -fr $PGDATA/pg_wal) 4.2 심볼릭 링크 생성 (ln -s /pg_wal $PGDATA/pg_wal) 5. pg_ctl start 초기 생성 시 WAL 경로 지정 initdb 명령으로 초기 생성 시 --waldi.. 2024. 3. 7. [PostgreSQL] auto_explain 사용/미사용 성능 테스트 DBMS: PostgreSQL 14.9 [목차여기] - auto_explain 사용 시 모든 SQL 실행통계 수집(성능저하 발생) - auto_explain.log_min_duration 값은 postgres.log 파일에 로깅 여부만 관여(지정 값보다 빨리 끝나서 미사용시와 동일한 성능나오는거 아님) - auto_explain.log_timing 값이 성능에 가장 많은 영향 - 꼭 사용하고 싶다면 auto_explain.log_timing 파라미터 off 고려해보자(구간별 수행시간 안나옴) 테스트 시나리오 auto_explain의 설정의 주요 파라미터인 아래 3개 파라미터의 값이 다른 환경에서 동일 SQL반복 수행 auto_explain.log_analyze auto_explain.log_buffers.. 2024. 2. 29. 이전 1 2 3 4 다음 반응형