[Postgres] 행을 향한 테이블과 열을 향한 테이블을 비교합니다.
개시하다
최근에 업무 중에, 나는 RDB를 막론하고 표에서 열을 관리하는 데이터베이스를 접할 기회가 있었다.
그래서 우리는 원래 줄로 되어 있던 탁자를 팀에 어떻게 놓아 성능에 영향을 미치는지 조사했다.
데이터의 역사(버전)를 관리하기 위해 열에 데이터를 가지고 있어야 하는 사람에게도 참고 가치가 있다고 생각합니다.
컨디션
% brew info postgresql
postgresql: stable 13.4 (bottled), HEAD
이번에 실행된 SQL
이쪽git에 기재되어 있다.
성능 테스트:행별 테이블
처리 ※ 1
테이블 작성
모두 얻다
찾다
창설
업데이트
삭제
시간(ms) ※ 2
5.7
6.6
1.3
1481.1
7736.5
5502.1
대략적인 시간(초)
1초 이하
1초 이하
1초 이하
1초
8초
6초
※ 한 줄 수는 10000줄
※ 2 반올림 소수 2위
성능 테스트: 열을 위한 테이블
처리 ※ 1
테이블 작성
모두 얻다
찾다
창설
업데이트
삭제
시간(ms) ※ 2
22.4
92.6
2.1
15878.8
108352.1
53893.3
대략적인 시간(초)
1초 이하
1초 이하
1초 이하
15초
108초
53초
※ 한 줄 수는 10000줄
※ 2 반올림 소수 2위
끝맺다
그 결과 열로 관리하면 성능이 많이 떨어지는 것으로 나타났다.
주의 사항
추가 1: 로그 파일 출력 방법
postgres=# SHOW config_file;
config_file
-----------------------------------------
/usr/local/var/postgres/postgresql.conf
(1 row)
Time: 0.398 ms
/usr/local/var/log
$ grep "2021-xx-xx 11:50:" postgres.log >> /Users/mac/Psql/ColumnOrientedDatabase/Sql/Insert/Performance/Performance.log
추가 2: 로그 파일에서 시간만 가져오는 모듈
다음 디렉토리(/Users/mac/Psql/Ext r actTimeFrom PerformanceLog)에서는 기록 파일에서 시간만 꺼내는 모듈이 만들어졌습니다.파일을 실행할 때 첫 번째 매개 변수로 해당하는 기록 파일을 지정하면 이 기록 파일에 기재된 시간을 합쳐서 출력합니다.
$ python3 /Users/mac/Psql/ExtractTimeFromPerformanceLog/ExtractTimeFromPerformanceLog.py /Users/mac/Psql/RowOrientedDatabase/Sql/Delete/Performance/Performance.log
5502.076999999987ms
경품 3:목록 구성
$ tree
.
├── ColumnOrientedDatabase
│ ├── Csv
│ │ ├── Output
│ │ │ └── 10000Rows.csv
│ │ └── Process
│ │ └── CreateCsv.py
│ ├── Sql
│ │ ├── CreateTable
│ │ │ ├── Output
│ │ │ │ └── CreateTable.sql
│ │ │ └── Performance
│ │ │ └── Performance.log
│ │ ├── Delete
│ │ │ ├── Output
│ │ │ │ └── Delete.sql
│ │ │ ├── Performance
│ │ │ │ └── Performance.log
│ │ │ └── Process
│ │ │ └── Delete.py
│ │ ├── Insert
│ │ │ ├── Output
│ │ │ │ └── Insert.sql
│ │ │ ├── Performance
│ │ │ │ └── Performance.log
│ │ │ └── Process
│ │ │ └── Insert.py
│ │ ├── Search
│ │ │ ├── Output
│ │ │ │ └── Search.sql
│ │ │ └── Performance
│ │ │ └── Performance.log
│ │ ├── Select
│ │ │ ├── Output
│ │ │ │ └── Select.sql
│ │ │ └── Performance
│ │ │ └── Performance.log
│ │ └── Update
│ │ ├── Output
│ │ │ └── Update.sql
│ │ ├── Performance
│ │ │ └── Performance.log
│ │ └── Process
│ │ └── Update.py
│ └── Uml
│ ├── Er.pu
│ └── Erd.png
├── ExtractTimeFromPerformanceLog
│ └── ExtractTimeFromPerformanceLog.py
├── README.md
└── RowOrientedDatabase
├── Csv
│ ├── Output
│ │ └── Matrix.csv
│ └── Process
│ └── CreateCsvMatrix.py
├── Sql
│ ├── CreateTable
│ │ ├── Output
│ │ │ └── CreateTable.sql
│ │ └── Performance
│ │ └── Performance.log
│ ├── Delete
│ │ ├── Output
│ │ │ └── Delete.sql
│ │ ├── Performance
│ │ │ └── Performance.log
│ │ └── Process
│ │ └── Delete.py
│ ├── Insert
│ │ ├── Output
│ │ │ └── Insert.sql
│ │ ├── Performance
│ │ │ └── Performance.log
│ │ └── Process
│ │ └── Insert.py
│ ├── Search
│ │ ├── Output
│ │ │ └── Search.sql
│ │ └── Performance
│ │ └── Performance.log
│ ├── Select
│ │ ├── Output
│ │ │ └── Select.sql
│ │ └── Performance
│ │ └── Performance.log
│ └── Update
│ ├── Output
│ │ └── Update.sql
│ ├── Performance
│ │ └── Performance.log
│ └── Process
│ └── Update.py
└── Uml
├── Er.pu
└── Erd.png
55 directories, 40 files
Reference
이 문제에 관하여([Postgres] 행을 향한 테이블과 열을 향한 테이블을 비교합니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/kensuke/articles/technote-psql-table-performance텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)